File: file-raw-placeholder.c

package info (click to toggle)
gimp 3.0.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 210,076 kB
  • sloc: ansic: 842,287; lisp: 10,761; python: 10,318; cpp: 7,238; perl: 4,355; sh: 1,043; xml: 963; yacc: 609; lex: 348; javascript: 150; makefile: 43
file content (189 lines) | stat: -rw-r--r-- 6,541 bytes parent folder | download
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/* GIMP - The GNU Image Manipulation Program
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
 * file-raw-placeholder.c -- raw file format plug-in that does nothing
 *                           except warning that there is no raw plug-in
 * Copyright (C) 2017 Michael Natterer <mitch@gimp.org>
 * Copyright (C) 2016 Tobias Ellinghaus <me@houz.org>
 *
 * 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 <https://www.gnu.org/licenses/>.
 */

#include "config.h"

#include <libgimp/gimp.h>

#include "libgimp/stdplugins-intl.h"

#include "file-raw-formats.h"


typedef struct _Placeholder      Placeholder;
typedef struct _PlaceholderClass PlaceholderClass;

struct _Placeholder
{
  GimpPlugIn      parent_instance;
};

struct _PlaceholderClass
{
  GimpPlugInClass parent_class;
};


#define PLACEHOLDER_TYPE  (placeholder_get_type ())
#define PLACEHOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PLACEHOLDER_TYPE, Placeholder))

GType                   placeholder_get_type         (void) G_GNUC_CONST;

static GList          * placeholder_query_procedures (GimpPlugIn            *plug_in);
static GimpProcedure  * placeholder_create_procedure (GimpPlugIn            *plug_in,
                                                      const gchar           *name);

static GimpValueArray * placeholder_load             (GimpProcedure         *procedure,
                                                      GimpRunMode            run_mode,
                                                      GFile                 *file,
                                                      GimpMetadata          *metadata,
                                                      GimpMetadataLoadFlags *flags,
                                                      GimpProcedureConfig   *config,
                                                      gpointer               run_data);


G_DEFINE_TYPE (Placeholder, placeholder, GIMP_TYPE_PLUG_IN)

GIMP_MAIN (PLACEHOLDER_TYPE)
DEFINE_STD_SET_I18N


static void
placeholder_class_init (PlaceholderClass *klass)
{
  GimpPlugInClass *plug_in_class = GIMP_PLUG_IN_CLASS (klass);

  plug_in_class->query_procedures = placeholder_query_procedures;
  plug_in_class->create_procedure = placeholder_create_procedure;
  plug_in_class->set_i18n         = STD_SET_I18N;
}

static void
placeholder_init (Placeholder *placeholder)
{
}

static GList *
placeholder_query_procedures (GimpPlugIn *plug_in)
{
  GList *list = NULL;
  gint   i;

  for (i = 0; i < G_N_ELEMENTS (file_formats); i++)
    {
      const FileFormat *format = &file_formats[i];
      gchar            *load_proc;

      load_proc = g_strdup_printf (format->load_proc_format,
                                   "raw-placeholder");

      list = g_list_append (list, load_proc);
    }

  return list;
}

static GimpProcedure *
placeholder_create_procedure (GimpPlugIn  *plug_in,
                              const gchar *name)
{
  GimpProcedure *procedure = NULL;
  gint           i;

  for (i = 0; i < G_N_ELEMENTS (file_formats); i++)
    {
      const FileFormat *format = &file_formats[i];
      gchar            *load_proc;
      gchar            *load_blurb;
      gchar            *load_help;

      load_proc = g_strdup_printf (format->load_proc_format,
                                   "raw-placeholder");

      if (strcmp (name, load_proc))
        {
          g_free (load_proc);
          continue;
        }

      load_blurb = g_strdup_printf (format->load_blurb_format, "placeholder");
      load_help  = g_strdup_printf (format->load_help_format,  "placeholder");

      procedure = gimp_load_procedure_new (plug_in, name,
                                           GIMP_PDB_PROC_TYPE_PLUGIN,
                                           placeholder_load,
                                           (gpointer) format, NULL);

      gimp_procedure_set_documentation (procedure,
                                        load_blurb, load_help, name);
      gimp_procedure_set_attribution (procedure,
                                      "Tobias Ellinghaus",
                                      "Tobias Ellinghaus",
                                      "2016");

      gimp_file_procedure_set_mime_types (GIMP_FILE_PROCEDURE (procedure),
                                          format->mime_type);
      gimp_file_procedure_set_extensions (GIMP_FILE_PROCEDURE (procedure),
                                          format->extensions);
      gimp_file_procedure_set_magics (GIMP_FILE_PROCEDURE (procedure),
                                      format->magic);

      gimp_load_procedure_set_handles_raw (GIMP_LOAD_PROCEDURE (procedure),
                                           TRUE);

      g_free (load_proc);
      g_free (load_blurb);
      g_free (load_help);

      break;
    }

  return procedure;
}

static GimpValueArray *
placeholder_load (GimpProcedure         *procedure,
                  GimpRunMode            run_mode,
                  GFile                 *file,
                  GimpMetadata          *metadata,
                  GimpMetadataLoadFlags *flags,
                  GimpProcedureConfig   *config,
                  gpointer               run_data)
{
  const FileFormat *format = run_data;
  GError           *error = NULL;

  g_set_error (&error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
               _("There is no RAW loader installed to open '%s' files.\n"
                 "\n"
                 "GIMP currently supports these RAW loaders:\n"
                 "- darktable (http://www.darktable.org/), at least 1.7\n"
                 "- RawTherapee (http://rawtherapee.com/), at least 5.2\n"
                 "\n"
                 "Please install one of them in order to "
                 "load RAW files."),
               gettext (format->file_type));

  return gimp_procedure_new_return_values (procedure,
                                           GIMP_PDB_EXECUTION_ERROR,
                                           error);
}