From 59558f8778899e48118bed79db2247f7bcecee04 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Mon, 24 Jul 2017 20:41:41 +0200 Subject: [PATCH] plug-ins: replace file-raw/file-formats.h's "darktable" strings by "%s" and assemble the actual strings dynamically, substituting "draktable". --- plug-ins/file-raw/file-darktable.c | 33 ++++-- plug-ins/file-raw/file-formats.h | 156 ++++++++++++++--------------- 2 files changed, 102 insertions(+), 87 deletions(-) diff --git a/plug-ins/file-raw/file-darktable.c b/plug-ins/file-raw/file-darktable.c index d37e1bc8ae..99fbf7e6e8 100644 --- a/plug-ins/file-raw/file-darktable.c +++ b/plug-ins/file-raw/file-darktable.c @@ -275,10 +275,17 @@ init (void) 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; - gimp_install_procedure (format->load_proc, - format->load_blurb, - format->load_help, + load_proc = g_strdup_printf (format->load_proc_format, "darktable"); + load_blurb = g_strdup_printf (format->load_blurb_format, "darktable"); + load_help = g_strdup_printf (format->load_help_format, "darktable"); + + gimp_install_procedure (load_proc, + load_blurb, + load_help, "Tobias Ellinghaus", "Tobias Ellinghaus", "2016", @@ -289,15 +296,19 @@ init (void) G_N_ELEMENTS (load_return_vals), load_args, load_return_vals); - gimp_register_file_handler_mime (format->load_proc, + gimp_register_file_handler_mime (load_proc, format->mime_type); - gimp_register_file_handler_raw (format->load_proc); - gimp_register_magic_load_handler (format->load_proc, + gimp_register_file_handler_raw (load_proc); + gimp_register_magic_load_handler (load_proc, format->extensions, "", format->magic); - gimp_register_thumbnail_loader (format->load_proc, LOAD_THUMB_PROC); + gimp_register_thumbnail_loader (load_proc, LOAD_THUMB_PROC); + + g_free (load_proc); + g_free (load_blurb); + g_free (load_help); } } @@ -339,9 +350,13 @@ run (const gchar *name, /* 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]; + const FileFormat *format = &file_formats[i]; + gchar *load_proc = NULL; - if (format->load_proc && ! strcmp (name, format->load_proc)) + if (format->load_proc_format) + load_proc = g_strdup_printf (format->load_proc_format, "darktable"); + + if (load_proc && ! strcmp (name, load_proc)) { image_ID = load_image (param[1].data.d_string, run_mode, &error); diff --git a/plug-ins/file-raw/file-formats.h b/plug-ins/file-raw/file-formats.h index f19902d0ad..d6abb14e0c 100644 --- a/plug-ins/file-raw/file-formats.h +++ b/plug-ins/file-raw/file-formats.h @@ -29,9 +29,9 @@ struct _FileFormat const gchar *extensions; const gchar *magic; - const gchar *load_proc; - const gchar *load_blurb; - const gchar *load_help; + const gchar *load_proc_format; + const gchar *load_blurb_format; + const gchar *load_help_format; }; /* some magic numbers taken from @@ -52,9 +52,9 @@ static const FileFormat file_formats[] = "0,string,MM\\0*\\0\\0\\021\\064\\0\\04," /* tiff */ "0,string,II*\\0\\0\\03\\0\\0\\0377\\01", /* tiff */ - "file-darktable-canon-load", - "Load files in the Canon raw formats via darktable", - "This plug-in loads files in Canon's raw formats by calling darktable." + "file-%s-canon-load", + "Load files in the Canon raw formats via %s", + "This plug-in loads files in Canon's raw formats by calling %s." }, { @@ -63,9 +63,9 @@ static const FileFormat file_formats[] = "nef,nrw", NULL, - "file-darktable-nikon-load", - "Load files in the Nikon raw formats via darktable", - "This plug-in loads files in Nikon's raw formats by calling darktable." + "file-%s-nikon-load", + "Load files in the Nikon raw formats via %s", + "This plug-in loads files in Nikon's raw formats by calling %s." }, { @@ -74,9 +74,9 @@ static const FileFormat file_formats[] = "3fr,fff", NULL, - "file-darktable-hasselblad-load", - "Load files in the Hasselblad raw formats via darktable", - "This plug-in loads files in Hasselblad's raw formats by calling darktable." + "file-%s-hasselblad-load", + "Load files in the Hasselblad raw formats via %s", + "This plug-in loads files in Hasselblad's raw formats by calling %s." }, { @@ -85,9 +85,9 @@ static const FileFormat file_formats[] = "arw,srf,sr2", NULL, - "file-darktable-sony-load", - "Load files in the Sony raw formats via darktable", - "This plug-in loads files in Sony's raw formats by calling darktable." + "file-%s-sony-load", + "Load files in the Sony raw formats via %s", + "This plug-in loads files in Sony's raw formats by calling %s." }, { @@ -96,9 +96,9 @@ static const FileFormat file_formats[] = "bay", NULL, - "file-darktable-bay-load", - "Load files in the BAY raw format via darktable", - "This plug-in loads files in Casio's raw BAY format by calling darktable." + "file-%s-bay-load", + "Load files in the BAY raw format via %s", + "This plug-in loads files in Casio's raw BAY format by calling %s." }, { @@ -107,9 +107,9 @@ static const FileFormat file_formats[] = "cine,cin", NULL, - "file-darktable-cine-load", - "Load files in the CINE raw format via darktable", - "This plug-in loads files in Phantom Software's raw CINE format by calling darktable." + "file-%s-cine-load", + "Load files in the CINE raw format via %s", + "This plug-in loads files in Phantom Software's raw CINE format by calling %s." }, { @@ -118,9 +118,9 @@ static const FileFormat file_formats[] = "cs1,ia,sti", NULL, - "file-darktable-sinar-load", - "Load files in the Sinar raw formats via darktable", - "This plug-in loads files in Sinar's raw formats by calling darktable." + "file-%s-sinar-load", + "Load files in the Sinar raw formats via %s", + "This plug-in loads files in Sinar's raw formats by calling %s." }, { @@ -130,9 +130,9 @@ static const FileFormat file_formats[] = "0,string,MM\\0*\\0\\0\\021\\0166\\0\\04," /* tiff */ "0,string,II*\\0\\0\\03\\0\\0\\0174\\01", /* tiff */ - "file-darktable-kodak-load", - "Load files in the Kodak raw formats via darktable", - "This plug-in loads files in Kodak's raw formats by calling darktable." + "file-%s-kodak-load", + "Load files in the Kodak raw formats via %s", + "This plug-in loads files in Kodak's raw formats by calling %s." }, { @@ -141,9 +141,9 @@ static const FileFormat file_formats[] = "dng", NULL, - "file-darktable-dng-load", - "Load files in the DNG raw format via darktable", - "This plug-in loads files in the Adobe Digital Negative DNG format by calling darktable." + "file-%s-dng-load", + "Load files in the DNG raw format via %s", + "This plug-in loads files in the Adobe Digital Negative DNG format by calling %s." }, { @@ -152,9 +152,9 @@ static const FileFormat file_formats[] = "erf", NULL, - "file-darktable-erf-load", - "Load files in the ERF raw format via darktable", - "This plug-in loads files in Epson's raw ERF format by calling darktable." + "file-%s-erf-load", + "Load files in the ERF raw format via %s", + "This plug-in loads files in Epson's raw ERF format by calling %s." }, { @@ -163,9 +163,9 @@ static const FileFormat file_formats[] = "cap,iiq", NULL, - "file-darktable-phaseone-load", - "Load files in the Phase One raw formats via darktable", - "This plug-in loads files in Phase One's raw formats by calling darktable." + "file-%s-phaseone-load", + "Load files in the Phase One raw formats via %s", + "This plug-in loads files in Phase One's raw formats by calling %s." }, { @@ -174,9 +174,9 @@ static const FileFormat file_formats[] = "mdc,mrw", NULL, - "file-darktable-minolta-load", - "Load files in the Minolta raw formats via darktable", - "This plug-in loads files in Minolta's raw formats by calling darktable." + "file-%s-minolta-load", + "Load files in the Minolta raw formats via %s", + "This plug-in loads files in Minolta's raw formats by calling %s." }, { @@ -184,9 +184,9 @@ static const FileFormat file_formats[] = "image/x-mamiya-mef", "mef", NULL, - "file-darktable-mef-load", - "Load files in the MEF raw format via darktable", - "This plug-in loads files in Mamiya's raw MEF format by calling darktable." + "file-%s-mef-load", + "Load files in the MEF raw format via %s", + "This plug-in loads files in Mamiya's raw MEF format by calling %s." }, { @@ -195,9 +195,9 @@ static const FileFormat file_formats[] = "mos", NULL, - "file-darktable-mos-load", - "Load files in the MOS raw format via darktable", - "This plug-in loads files in Leaf's raw MOS format by calling darktable." + "file-%s-mos-load", + "Load files in the MOS raw format via %s", + "This plug-in loads files in Leaf's raw MOS format by calling %s." }, { @@ -206,9 +206,9 @@ static const FileFormat file_formats[] = "orf", "0,string,IIRO,0,string,MMOR,0,string,IIRS", - "file-darktable-orf-load", - "Load files in the ORF raw format via darktable", - "This plug-in loads files in Olympus' raw ORF format by calling darktable." + "file-%s-orf-load", + "Load files in the ORF raw format via %s", + "This plug-in loads files in Olympus' raw ORF format by calling %s." }, { @@ -217,9 +217,9 @@ static const FileFormat file_formats[] = "pef,raw", NULL, - "file-darktable-pef-load", - "Load files in the PEF raw format via darktable", - "This plug-in loads files in Pentax' raw PEF format by calling darktable." + "file-%s-pef-load", + "Load files in the PEF raw format via %s", + "This plug-in loads files in Pentax' raw PEF format by calling %s." }, { @@ -228,9 +228,9 @@ static const FileFormat file_formats[] = "pxn", NULL, - "file-darktable-pxn-load", - "Load files in the PXN raw format via darktable", - "This plug-in loads files in Logitech's raw PXN format by calling darktable." + "file-%s-pxn-load", + "Load files in the PXN raw format via %s", + "This plug-in loads files in Logitech's raw PXN format by calling %s." }, { @@ -239,9 +239,9 @@ static const FileFormat file_formats[] = "qtk", NULL, - "file-darktable-qtk-load", - "Load files in the QTK raw format via darktable", - "This plug-in loads files in Apple's QuickTake QTK raw format by calling darktable." + "file-%s-qtk-load", + "Load files in the QTK raw format via %s", + "This plug-in loads files in Apple's QuickTake QTK raw format by calling %s." }, { @@ -250,9 +250,9 @@ static const FileFormat file_formats[] = "raf", "0,string,FUJIFILMCCD-RAW", - "file-darktable-raf-load", - "Load files in the RAF raw format via darktable", - "This plug-in loads files in Fujifilm's raw RAF format by calling darktable." + "file-%s-raf-load", + "Load files in the RAF raw format via %s", + "This plug-in loads files in Fujifilm's raw RAF format by calling %s." }, { @@ -261,9 +261,9 @@ static const FileFormat file_formats[] = "raw,rw2", "0,string,IIU\\0", - "file-darktable-panasonic-load", - "Load files in the Panasonic raw formats via darktable", - "This plug-in loads files in Panasonic's raw formats by calling darktable." + "file-%s-panasonic-load", + "Load files in the Panasonic raw formats via %s", + "This plug-in loads files in Panasonic's raw formats by calling %s." }, { @@ -272,9 +272,9 @@ static const FileFormat file_formats[] = "rdc", NULL, - "file-darktable-rdc-load", - "Load files in the RDC raw format via darktable", - "This plug-in loads files in Digital Foto Maker's raw RDC format by calling darktable." + "file-%s-rdc-load", + "Load files in the RDC raw format via %s", + "This plug-in loads files in Digital Foto Maker's raw RDC format by calling %s." }, { @@ -283,9 +283,9 @@ static const FileFormat file_formats[] = "rwl", NULL, - "file-darktable-rwl-load", - "Load files in the RWL raw format via darktable", - "This plug-in loads files in Leica's raw RWL format by calling darktable." + "file-%s-rwl-load", + "Load files in the RWL raw format via %s", + "This plug-in loads files in Leica's raw RWL format by calling %s." }, { @@ -294,9 +294,9 @@ static const FileFormat file_formats[] = "srw", NULL, - "file-darktable-srw-load", - "Load files in the SRW raw format via darktable", - "This plug-in loads files in Samsung's raw SRW format by calling darktable." + "file-%s-srw-load", + "Load files in the SRW raw format via %s", + "This plug-in loads files in Samsung's raw SRW format by calling %s." }, { @@ -305,9 +305,9 @@ static const FileFormat file_formats[] = "x3f", "0,string,FOVb", - "file-darktable-x3f-load", - "Load files in the X3F raw format via darktable", - "This plug-in loads files in Sigma's raw X3F format by calling darktable." + "file-%s-x3f-load", + "Load files in the X3F raw format via %s", + "This plug-in loads files in Sigma's raw X3F format by calling %s." }, { @@ -316,8 +316,8 @@ static const FileFormat file_formats[] = "ari", NULL, - "file-darktable-ari-load", - "Load files in the ARI raw format via darktable", - "This plug-in loads files in Arriflex' raw ARI format by calling darktable." + "file-%s-ari-load", + "Load files in the ARI raw format via %s", + "This plug-in loads files in Arriflex' raw ARI format by calling %s." } };