[gimp] Bug 784261 - Have some nice error message for formats known to work...
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 784261 - Have some nice error message for formats known to work...
- Date: Mon, 24 Jul 2017 20:23:28 +0000 (UTC)
commit 713995e27d0db6f77e1dd3092a08ee8ca8c14b96
Author: Michael Natterer <mitch gimp org>
Date: Mon Jul 24 22:19:53 2017 +0200
Bug 784261 - Have some nice error message for formats known to work...
...with known plugins
Add new plug-in file-raw-placeholder.c that registers itself for
loading all RAW formats from file-raw/file-formats.h, but does nothing
except returning an error message pointing to darktable and
RawTherapee.
When no real RAW loader is installed, this plug-in is selected
automatically as RAW loader, otherwise the first installed RAW loader
is used. Selecting another in prefs still works as before.
app/plug-in/gimppluginmanager-restore.c | 38 ++++++-
plug-ins/file-raw/.gitignore | 2 +
plug-ins/file-raw/Makefile.am | 19 +++-
plug-ins/file-raw/file-raw-placeholder.c | 164 ++++++++++++++++++++++++++++++
po-plug-ins/POTFILES.in | 1 +
5 files changed, 216 insertions(+), 8 deletions(-)
---
diff --git a/app/plug-in/gimppluginmanager-restore.c b/app/plug-in/gimppluginmanager-restore.c
index 3ff8639..761f402 100644
--- a/app/plug-in/gimppluginmanager-restore.c
+++ b/app/plug-in/gimppluginmanager-restore.c
@@ -879,8 +879,13 @@ gimp_plug_in_manager_sort_file_procs (GimpPlugInManager *manager)
if (config->import_raw_plug_in)
- config_plug_in = gimp_file_new_for_config_path (config->import_raw_plug_in,
- NULL);
+ {
+ /* remember the configured raw loader, unless it's the placeholder */
+ if (! strstr (config->import_raw_plug_in, "file-raw-placeholder"))
+ config_plug_in =
+ gimp_file_new_for_config_path (config->import_raw_plug_in,
+ NULL);
+ }
/* make the list of raw loaders, and remember the one configured in
* config if found
@@ -911,16 +916,37 @@ gimp_plug_in_manager_sort_file_procs (GimpPlugInManager *manager)
g_object_unref (config_plug_in);
/* if no raw loader was configured, or the configured raw loader
- * wasn't found, default to the first loader, if any
+ * wasn't found, default to the first loader that is not the
+ * placeolder, if any
*/
if (! raw_plug_in && manager->raw_load_procs)
{
gchar *path;
- raw_plug_in =
- gimp_plug_in_procedure_get_file (manager->raw_load_procs->data);
+ for (list = manager->raw_load_procs; list; list = g_slist_next (list))
+ {
+ GimpPlugInProcedure *file_proc = list->data;
+
+ raw_plug_in = gimp_plug_in_procedure_get_file (file_proc);
+
+ path = gimp_file_get_config_path (raw_plug_in, NULL);
+
+ if (! strstr (path, "file-raw-placeholder"))
+ break;
- path = gimp_file_get_config_path (raw_plug_in, NULL);
+ g_free (path);
+ path = NULL;
+
+ raw_plug_in = NULL;
+ }
+
+ if (! raw_plug_in)
+ {
+ raw_plug_in =
+ gimp_plug_in_procedure_get_file (manager->raw_load_procs->data);
+
+ path = gimp_file_get_config_path (raw_plug_in, NULL);
+ }
g_object_set (config,
"import-raw-plug-in", path,
diff --git a/plug-ins/file-raw/.gitignore b/plug-ins/file-raw/.gitignore
index b9ce867..c4708a1 100644
--- a/plug-ins/file-raw/.gitignore
+++ b/plug-ins/file-raw/.gitignore
@@ -7,3 +7,5 @@
/file-darktable.exe
/file-rawtherapee
/file-rawtherapee.exe
+/file-raw-placeholder
+/file-raw-placeholder.exe
diff --git a/plug-ins/file-raw/Makefile.am b/plug-ins/file-raw/Makefile.am
index 72f59de..bf3bcc6 100644
--- a/plug-ins/file-raw/Makefile.am
+++ b/plug-ins/file-raw/Makefile.am
@@ -13,6 +13,7 @@ endif
# include $(top_srcdir)/build/windows/gimprc-plug-ins.rule
# file_darktable_RC = file-darktable.rc.o
# file_rawtherapee_RC = file-rawtherapee.rc.o
+# file_raw_placeholder_RC = file-raw-placeholder.rc.o
# endif
AM_LDFLAGS = $(mwindows)
@@ -26,8 +27,9 @@ AM_CPPFLAGS = \
$(GEGL_CFLAGS)
libexec_PROGRAMS = \
- file-darktable \
- file-rawtherapee
+ file-darktable \
+ file-rawtherapee \
+ file-raw-placeholder
file_darktable_SOURCES = \
file-darktable.c \
@@ -37,6 +39,10 @@ file_rawtherapee_SOURCES = \
file-rawtherapee.c \
file-formats.h
+file_raw_placeholder_SOURCES = \
+ file-raw-placeholder.c \
+ file-formats.h
+
file_darktable_LDADD = \
$(libgimp) \
$(libgimpbase) \
@@ -55,6 +61,15 @@ file_rawtherapee_LDADD = \
$(INTLLIBS) \
$(file_rawtherapee_RC)
+file_raw_placeholder_LDADD = \
+ $(libgimp) \
+ $(libgimpbase) \
+ $(CAIRO_LIBS) \
+ $(GEGL_LIBS) \
+ $(RT_LIBS) \
+ $(INTLLIBS) \
+ $(file_raw_placeholder_RC)
+
filerawdata_DATA = \
file-darktable-export-on-exit.lua \
file-darktable-get-size.lua
diff --git a/plug-ins/file-raw/file-raw-placeholder.c b/plug-ins/file-raw/file-raw-placeholder.c
new file mode 100644
index 0000000..28b2b66
--- /dev/null
+++ b/plug-ins/file-raw/file-raw-placeholder.c
@@ -0,0 +1,164 @@
+/* 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 <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <libgimp/gimp.h>
+#include <libgimp/gimpui.h>
+
+#include "libgimp/stdplugins-intl.h"
+
+#include "file-formats.h"
+
+
+static void query (void);
+static void run (const gchar *name,
+ gint nparams,
+ const GimpParam *param,
+ gint *nreturn_vals,
+ GimpParam **return_vals);
+
+
+const GimpPlugInInfo PLUG_IN_INFO =
+{
+ NULL, /* init_proc */
+ NULL, /* quit_proc */
+ query, /* query proc */
+ run, /* run_proc */
+};
+
+
+MAIN ()
+
+
+static void
+query (void)
+{
+ static const GimpParamDef load_args[] =
+ {
+ { GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" },
+ { GIMP_PDB_STRING, "filename", "The name of the file to load." },
+ { GIMP_PDB_STRING, "raw-filename", "The name entered" },
+ };
+
+ static const GimpParamDef load_return_vals[] =
+ {
+ { GIMP_PDB_IMAGE, "image", "Output image" }
+ };
+
+ 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");
+ load_blurb = g_strdup_printf (format->load_blurb_format, "raw-placeholder");
+ load_help = g_strdup_printf (format->load_help_format, "raw-placeholder");
+
+ gimp_install_procedure (load_proc,
+ load_blurb,
+ load_help,
+ "Tobias Ellinghaus",
+ "Tobias Ellinghaus",
+ "2016",
+ format->file_type,
+ NULL,
+ GIMP_PLUGIN,
+ G_N_ELEMENTS (load_args),
+ G_N_ELEMENTS (load_return_vals),
+ load_args, load_return_vals);
+
+ gimp_register_file_handler_mime (load_proc,
+ format->mime_type);
+ gimp_register_file_handler_raw (load_proc);
+ gimp_register_magic_load_handler (load_proc,
+ format->extensions,
+ "",
+ format->magic);
+
+ g_free (load_proc);
+ g_free (load_blurb);
+ g_free (load_help);
+ }
+}
+
+static void
+run (const gchar *name,
+ gint nparams,
+ const GimpParam *param,
+ gint *nreturn_vals,
+ GimpParam **return_vals)
+{
+ static GimpParam values[6];
+ GimpPDBStatusType status = GIMP_PDB_EXECUTION_ERROR;
+ GError *error = NULL;
+ gint i;
+
+ INIT_I18N ();
+
+ *nreturn_vals = 1;
+ *return_vals = values;
+
+ values[0].type = GIMP_PDB_STATUS;
+ values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
+
+ /* check if the format passed is actually supported & load */
+ for (i = 0; i < G_N_ELEMENTS (file_formats); i++)
+ {
+ const FileFormat *format = &file_formats[i];
+ gchar *load_proc = NULL;
+
+ if (format->load_proc_format)
+ load_proc = g_strdup_printf (format->load_proc_format, "raw-placeholder");
+
+ if (load_proc && ! strcmp (name, load_proc))
+ {
+ 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/)\n"
+ "RawTherapee (http://rawtherapee.com/)\n"
+ "\n"
+ "Please install one of them in order to "
+ "load RAW files."),
+ gettext (format->file_type));
+ break;
+ }
+ }
+
+ if (i == G_N_ELEMENTS (file_formats))
+ status = GIMP_PDB_CALLING_ERROR;
+
+ if (status != GIMP_PDB_SUCCESS && error)
+ {
+ *nreturn_vals = 2;
+ values[1].type = GIMP_PDB_STRING;
+ values[1].data.d_string = error->message;
+ }
+
+ values[0].data.d_status = status;
+}
diff --git a/po-plug-ins/POTFILES.in b/po-plug-ins/POTFILES.in
index d61748f..60ee619 100644
--- a/po-plug-ins/POTFILES.in
+++ b/po-plug-ins/POTFILES.in
@@ -118,6 +118,7 @@ plug-ins/file-psd/psd-util.c
plug-ins/file-psd/psd.c
plug-ins/file-raw/file-darktable.c
plug-ins/file-raw/file-formats.h
+plug-ins/file-raw/file-raw-placeholder.c
plug-ins/file-raw/file-rawtherapee.c
plug-ins/file-sgi/sgi.c
plug-ins/file-tiff/file-tiff.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]