plug-ins: Port more plug-ins to GimpChoice

This replaces most of the remaining
gimp_procedure_dialog_get_int_combo ()
parameters with defined GimpChoice
parameters.
The only exceptions are where we retrieve
the values from a library (such as file-aa)
or the integer value itself is intuitive
(such as bit-depth or rotation degree)
This commit is contained in:
Alx Sa 2024-08-19 14:40:46 +00:00
parent d7806d92ec
commit 8dd7783fc2
13 changed files with 263 additions and 314 deletions

View File

@ -217,14 +217,15 @@ gif_create_procedure (GimpPlugIn *plug_in,
0, G_MAXINT, 100, 0, G_MAXINT, 100,
G_PARAM_READWRITE); G_PARAM_READWRITE);
gimp_procedure_add_int_argument (procedure, "default-dispose", gimp_procedure_add_choice_argument (procedure, "default-dispose",
_("Frame disposal _when unspecified"), _("Frame disposal _when unspecified"),
_("(animated gif) Default disposal type " _("(animated gif) Default disposal type"),
"(0=`don't care`, " gimp_choice_new_with_values ("unspecified", DISPOSE_UNSPECIFIED, _("I don't care"), NULL,
"1=combine, " "combine", DISPOSE_COMBINE, _("Cumulative layers (combine)"), NULL,
"2=replace)"), "replace", DISPOSE_REPLACE, _("One frame per layer (replace)"), NULL,
0, 2, 0, NULL),
G_PARAM_READWRITE); "unspecified",
G_PARAM_READWRITE);
gimp_procedure_add_boolean_argument (procedure, "as-animation", gimp_procedure_add_boolean_argument (procedure, "as-animation",
_("_As animation"), _("_As animation"),
@ -795,13 +796,15 @@ export_image (GFile *file,
"loop", &config_loop, "loop", &config_loop,
"number-of-repeats", &config_number_of_repeats, "number-of-repeats", &config_number_of_repeats,
"default-delay", &config_default_delay, "default-delay", &config_default_delay,
"default-dispose", &config_default_dispose,
"force-delay", &config_use_default_delay, "force-delay", &config_use_default_delay,
"force-dispose", &config_use_default_dispose, "force-dispose", &config_use_default_dispose,
"as-animation", &config_as_animation, "as-animation", &config_as_animation,
"save-comment", &config_save_comment, "save-comment", &config_save_comment,
"gimp-comment", &config_comment, "gimp-comment", &config_comment,
NULL); NULL);
config_default_dispose =
gimp_procedure_config_get_choice_id (GIMP_PROCEDURE_CONFIG (config),
"default-dispose");
/* The GIF spec says 7bit ASCII for the comment block. */ /* The GIF spec says 7bit ASCII for the comment block. */
if (config_save_comment && config_comment && strlen (config_comment)) if (config_save_comment && config_comment && strlen (config_comment))
@ -1314,7 +1317,6 @@ save_dialog (GimpImage *image,
{ {
GtkWidget *grid; GtkWidget *grid;
GtkWidget *widget; GtkWidget *widget;
GtkListStore *store;
grid = gtk_grid_new (); grid = gtk_grid_new ();
gtk_grid_set_column_spacing (GTK_GRID (grid), 1); gtk_grid_set_column_spacing (GTK_GRID (grid), 1);
@ -1350,16 +1352,9 @@ save_dialog (GimpImage *image,
gtk_grid_attach (GTK_GRID (grid), widget, 1, 1, 1, 1); gtk_grid_attach (GTK_GRID (grid), widget, 1, 1, 1, 1);
gtk_widget_set_visible (widget, TRUE); gtk_widget_set_visible (widget, TRUE);
store = gimp_int_store_new (_("I don't care"), widget = gimp_procedure_dialog_get_widget (GIMP_PROCEDURE_DIALOG (dialog),
DISPOSE_UNSPECIFIED, "default-dispose",
_("Cumulative layers (combine)"), G_TYPE_NONE);
DISPOSE_COMBINE,
_("One frame per layer (replace)"),
DISPOSE_REPLACE,
NULL);
widget = gimp_procedure_dialog_get_int_combo (GIMP_PROCEDURE_DIALOG (dialog),
"default-dispose",
GIMP_INT_STORE (store));
gtk_grid_attach (GTK_GRID (grid), widget, 0, 2, 2, 1); gtk_grid_attach (GTK_GRID (grid), widget, 0, 2, 2, 1);
gtk_widget_set_visible (widget, TRUE); gtk_widget_set_visible (widget, TRUE);

View File

@ -282,19 +282,25 @@ heif_create_procedure (GimpPlugIn *plug_in,
8, 12, 8, 8, 12, 8,
G_PARAM_READWRITE); G_PARAM_READWRITE);
gimp_procedure_add_int_argument (procedure, "pixel-format", gimp_procedure_add_choice_argument (procedure, "pixel-format",
_("_Pixel format"), _("_Pixel format"),
_("Format of color sub-sampling"), _("Format of color sub-sampling"),
HEIFPLUGIN_EXPORT_FORMAT_RGB, HEIFPLUGIN_EXPORT_FORMAT_YUV420, gimp_choice_new_with_values ("rgb", HEIFPLUGIN_EXPORT_FORMAT_RGB, _("RGB"), NULL,
HEIFPLUGIN_EXPORT_FORMAT_YUV420, "yuv444", HEIFPLUGIN_EXPORT_FORMAT_YUV444, _("YUV444"), NULL,
G_PARAM_READWRITE); "yuv420", HEIFPLUGIN_EXPORT_FORMAT_YUV420, _("YUV420"), NULL,
NULL),
"yuv420",
G_PARAM_READWRITE);
gimp_procedure_add_int_argument (procedure, "encoder-speed", gimp_procedure_add_choice_argument (procedure, "encoder-speed",
_("Enco_der speed"), _("Enco_der speed"),
_("Tradeoff between speed and compression"), _("Tradeoff between speed and compression"),
HEIFPLUGIN_ENCODER_SPEED_SLOW, HEIFPLUGIN_ENCODER_SPEED_FASTER, gimp_choice_new_with_values ("slow", HEIFPLUGIN_ENCODER_SPEED_SLOW, _("Slow"), NULL,
HEIFPLUGIN_ENCODER_SPEED_BALANCED, "balanced", HEIFPLUGIN_ENCODER_SPEED_BALANCED, _("Balanced"), NULL,
G_PARAM_READWRITE); "fast", HEIFPLUGIN_ENCODER_SPEED_FASTER, _("Fast"), NULL,
NULL),
"balanced",
G_PARAM_READWRITE);
gimp_procedure_add_boolean_argument (procedure, "save-exif", gimp_procedure_add_boolean_argument (procedure, "save-exif",
_("Save Exi_f"), _("Save Exi_f"),
@ -397,19 +403,25 @@ heif_create_procedure (GimpPlugIn *plug_in,
8, 12, 8, 8, 12, 8,
G_PARAM_READWRITE); G_PARAM_READWRITE);
gimp_procedure_add_int_argument (procedure, "pixel-format", gimp_procedure_add_choice_argument (procedure, "pixel-format",
_("_Pixel format"), _("_Pixel format"),
_("Format of color sub-sampling"), _("Format of color sub-sampling"),
HEIFPLUGIN_EXPORT_FORMAT_RGB, HEIFPLUGIN_EXPORT_FORMAT_YUV420, gimp_choice_new_with_values ("rgb", HEIFPLUGIN_EXPORT_FORMAT_RGB, _("RGB"), NULL,
HEIFPLUGIN_EXPORT_FORMAT_YUV420, "yuv444", HEIFPLUGIN_EXPORT_FORMAT_YUV444, _("YUV444"), NULL,
G_PARAM_READWRITE); "yuv420", HEIFPLUGIN_EXPORT_FORMAT_YUV420, _("YUV420"), NULL,
NULL),
"yuv420",
G_PARAM_READWRITE);
gimp_procedure_add_int_argument (procedure, "encoder-speed", gimp_procedure_add_choice_argument (procedure, "encoder-speed",
_("Enco_der speed"), _("Enco_der speed"),
_("Tradeoff between speed and compression"), _("Tradeoff between speed and compression"),
HEIFPLUGIN_ENCODER_SPEED_SLOW, HEIFPLUGIN_ENCODER_SPEED_FASTER, gimp_choice_new_with_values ("slow", HEIFPLUGIN_ENCODER_SPEED_SLOW, _("Slow"), NULL,
HEIFPLUGIN_ENCODER_SPEED_BALANCED, "balanced", HEIFPLUGIN_ENCODER_SPEED_BALANCED, _("Balanced"), NULL,
G_PARAM_READWRITE); "fast", HEIFPLUGIN_ENCODER_SPEED_FASTER, _("Fast"), NULL,
NULL),
"balanced",
G_PARAM_READWRITE);
gimp_procedure_add_boolean_argument (procedure, "save-exif", gimp_procedure_add_boolean_argument (procedure, "save-exif",
_("Save Exi_f"), _("Save Exi_f"),
@ -1428,13 +1440,17 @@ export_image (GFile *file,
g_object_get (config, g_object_get (config,
"lossless", &lossless, "lossless", &lossless,
"quality", &quality, "quality", &quality,
"pixel-format", &pixel_format,
"save-bit-depth", &save_bit_depth, "save-bit-depth", &save_bit_depth,
"encoder-speed", &encoder_speed,
"save-color-profile", &save_profile, "save-color-profile", &save_profile,
"save-exif", &save_exif, "save-exif", &save_exif,
"save-xmp", &save_xmp, "save-xmp", &save_xmp,
NULL); NULL);
pixel_format =
gimp_procedure_config_get_choice_id (GIMP_PROCEDURE_CONFIG (config),
"pixel-format");
encoder_speed =
gimp_procedure_config_get_choice_id (GIMP_PROCEDURE_CONFIG (config),
"encoder-speed");
if (compression == heif_compression_HEVC) if (compression == heif_compression_HEVC)
{ {
@ -2410,9 +2426,7 @@ save_dialog (GimpProcedure *procedure,
{ {
GtkWidget *dialog; GtkWidget *dialog;
GtkWidget *quality_scale; GtkWidget *quality_scale;
GtkListStore *store_pixelformats;
GtkListStore *store_bitdepths; GtkListStore *store_bitdepths;
GtkListStore *store_speeds;
gboolean run; gboolean run;
dialog = gimp_export_procedure_dialog_new (GIMP_EXPORT_PROCEDURE (procedure), dialog = gimp_export_procedure_dialog_new (GIMP_EXPORT_PROCEDURE (procedure),
@ -2431,14 +2445,6 @@ save_dialog (GimpProcedure *procedure,
G_BINDING_SYNC_CREATE | G_BINDING_SYNC_CREATE |
G_BINDING_INVERT_BOOLEAN); G_BINDING_INVERT_BOOLEAN);
store_pixelformats = gimp_int_store_new (_("RGB"), HEIFPLUGIN_EXPORT_FORMAT_RGB,
_("YUV444"), HEIFPLUGIN_EXPORT_FORMAT_YUV444,
_("YUV420"), HEIFPLUGIN_EXPORT_FORMAT_YUV420,
NULL);
gimp_procedure_dialog_get_int_combo (GIMP_PROCEDURE_DIALOG (dialog),
"pixel-format", GIMP_INT_STORE (store_pixelformats));
store_bitdepths = gimp_int_store_new (_("8 bit/channel"), 8, store_bitdepths = gimp_int_store_new (_("8 bit/channel"), 8,
_("10 bit/channel"), 10, _("10 bit/channel"), 10,
_("12 bit/channel"), 12, _("12 bit/channel"), 12,
@ -2447,14 +2453,6 @@ save_dialog (GimpProcedure *procedure,
gimp_procedure_dialog_get_int_combo (GIMP_PROCEDURE_DIALOG (dialog), gimp_procedure_dialog_get_int_combo (GIMP_PROCEDURE_DIALOG (dialog),
"save-bit-depth", GIMP_INT_STORE (store_bitdepths)); "save-bit-depth", GIMP_INT_STORE (store_bitdepths));
store_speeds = gimp_int_store_new (_("Slow"), HEIFPLUGIN_ENCODER_SPEED_SLOW,
_("Balanced"), HEIFPLUGIN_ENCODER_SPEED_BALANCED,
_("Fast"), HEIFPLUGIN_ENCODER_SPEED_FASTER,
NULL);
gimp_procedure_dialog_get_int_combo (GIMP_PROCEDURE_DIALOG (dialog),
"encoder-speed", GIMP_INT_STORE (store_speeds));
gimp_procedure_dialog_fill (GIMP_PROCEDURE_DIALOG (dialog), gimp_procedure_dialog_fill (GIMP_PROCEDURE_DIALOG (dialog),
"lossless", "quality", "lossless", "quality",
"pixel-format", "pixel-format",

View File

@ -245,12 +245,18 @@ jp2_create_procedure (GimpPlugIn *plug_in,
gimp_file_procedure_set_extensions (GIMP_FILE_PROCEDURE (procedure), gimp_file_procedure_set_extensions (GIMP_FILE_PROCEDURE (procedure),
"j2k,j2c,jpc"); "j2k,j2c,jpc");
gimp_procedure_add_int_argument (procedure, "colorspace", gimp_procedure_add_choice_argument (procedure, "colorspace",
_("Color s_pace"), _("Color s_pace"),
_("Color space { UNKNOWN (0), GRAYSCALE (1), RGB (2), " _("Color space"),
"CMYK (3), YCbCr (4), xvYCC (5) }"), gimp_choice_new_with_values ("srgb", OPJ_CLRSPC_SRGB, _("sRGB"), NULL,
0, 5, 0, "grayscale", OPJ_CLRSPC_GRAY, _("Grayscale"), NULL,
G_PARAM_READWRITE); "ycbcr", OPJ_CLRSPC_SYCC, _("YCbCr"), NULL,
"xvycc", OPJ_CLRSPC_EYCC, _("xvYCC"), NULL,
"cmyk", OPJ_CLRSPC_CMYK, _("CMYK"), NULL,
"unknown", OPJ_CLRSPC_UNKNOWN, _("Unknown"), NULL,
NULL),
"unknown",
G_PARAM_READWRITE);
} }
return procedure; return procedure;
@ -284,38 +290,9 @@ jp2_load (GimpProcedure *procedure,
default: default:
if (! strcmp (gimp_procedure_get_name (procedure), LOAD_J2K_PROC)) if (! strcmp (gimp_procedure_get_name (procedure), LOAD_J2K_PROC))
{ color_space =
gint color_space_argument = 0; gimp_procedure_config_get_choice_id (GIMP_PROCEDURE_CONFIG (config),
"colorspace");
g_object_get (config,
"colorspace", &color_space_argument,
NULL);
/* Order is not the same as OpenJPEG enum on purpose,
* since it's better to not rely on a given order or
* on enum values.
*/
switch (color_space_argument)
{
case 1:
color_space = OPJ_CLRSPC_GRAY;
break;
case 2:
color_space = OPJ_CLRSPC_SRGB;
break;
case 3:
color_space = OPJ_CLRSPC_CMYK;
break;
case 4:
color_space = OPJ_CLRSPC_SYCC;
break;
case 5:
color_space = OPJ_CLRSPC_EYCC;
break;
default:
break;
}
}
interactive = FALSE; interactive = FALSE;
break; break;
} }
@ -959,11 +936,11 @@ open_dialog (GimpProcedure *procedure,
gint num_components, gint num_components,
GError **error) GError **error)
{ {
const gchar *title; const gchar *title;
GtkWidget *dialog; GtkWidget *dialog;
GtkListStore *store = NULL; gboolean run;
gboolean run; GimpParamSpecChoice *cspec;
OPJ_COLOR_SPACE color_space = OPJ_CLRSPC_SRGB; OPJ_COLOR_SPACE color_space = OPJ_CLRSPC_SRGB;
if (format == OPJ_CODEC_J2K) if (format == OPJ_CODEC_J2K)
/* Not having color information is expected. */ /* Not having color information is expected. */
@ -978,27 +955,21 @@ open_dialog (GimpProcedure *procedure,
GIMP_PROCEDURE_CONFIG (config), GIMP_PROCEDURE_CONFIG (config),
_(title)); _(title));
gimp_dialog_set_alternative_button_order (GTK_DIALOG (dialog), cspec =
GTK_RESPONSE_OK, GIMP_PARAM_SPEC_CHOICE (g_object_class_find_property (G_OBJECT_GET_CLASS (config),
GTK_RESPONSE_CANCEL, "colorspace"));
-1);
if (num_components == 3) if (num_components == 3)
{ {
/* Can be RGB, YUV and YCC. */ /* Can be RGB, YUV and YCC. */
store = gimp_int_store_new (_("sRGB"), OPJ_CLRSPC_SRGB, gimp_choice_set_sensitive (cspec->choice, "grayscale", FALSE);
_("YCbCr"), OPJ_CLRSPC_SYCC, gimp_choice_set_sensitive (cspec->choice, "cmyk", FALSE);
_("xvYCC"), OPJ_CLRSPC_EYCC,
NULL);
} }
else if (num_components == 4) else if (num_components == 4)
{ {
/* Can be RGB, YUV and YCC with alpha or CMYK. */ /* Can be RGB, YUV and YCC with alpha or CMYK. */
store = gimp_int_store_new (_("sRGB"), OPJ_CLRSPC_SRGB, gimp_choice_set_sensitive (cspec->choice, "grayscale", FALSE);
_("YCbCr"), OPJ_CLRSPC_SYCC,
_("xvYCC"), OPJ_CLRSPC_EYCC,
_("CMYK"), OPJ_CLRSPC_CMYK,
NULL);
} }
else else
{ {
@ -1006,22 +977,20 @@ open_dialog (GimpProcedure *procedure,
_("Unsupported JPEG 2000%s '%s' with %d components."), _("Unsupported JPEG 2000%s '%s' with %d components."),
(format == OPJ_CODEC_J2K) ? " codestream" : "", (format == OPJ_CODEC_J2K) ? " codestream" : "",
gimp_file_get_utf8_name (file), num_components); gimp_file_get_utf8_name (file), num_components);
color_space = OPJ_CLRSPC_UNKNOWN;
g_object_set (config, "colorspace", "unknown", NULL);
} }
if (store) if (num_components == 3 || num_components == 4)
{ {
gimp_procedure_dialog_get_int_combo (GIMP_PROCEDURE_DIALOG (dialog),
"colorspace", GIMP_INT_STORE (store));
/* By default, RGB is active. */ /* By default, RGB is active. */
g_object_set (config, gimp_choice_set_sensitive (cspec->choice, "unknown", FALSE);
"colorspace", color_space, g_object_set (config, "colorspace", "srgb", NULL);
NULL);
gimp_procedure_dialog_fill (GIMP_PROCEDURE_DIALOG (dialog), gimp_procedure_dialog_fill (GIMP_PROCEDURE_DIALOG (dialog),
NULL); NULL);
gtk_widget_show (dialog); gtk_widget_set_visible (dialog, TRUE);
run = gimp_procedure_dialog_run (GIMP_PROCEDURE_DIALOG (dialog)); run = gimp_procedure_dialog_run (GIMP_PROCEDURE_DIALOG (dialog));
@ -1030,9 +999,9 @@ open_dialog (GimpProcedure *procedure,
* No error occurred. */ * No error occurred. */
color_space = OPJ_CLRSPC_UNKNOWN; color_space = OPJ_CLRSPC_UNKNOWN;
else else
g_object_get (config, color_space =
"colorspace", &color_space, gimp_procedure_config_get_choice_id (GIMP_PROCEDURE_CONFIG (config),
NULL); "colorspace");
} }
gtk_widget_destroy (dialog); gtk_widget_destroy (dialog);

View File

@ -207,12 +207,21 @@ jpegxl_create_procedure (GimpPlugIn *plug_in,
8, 16, 8, 8, 16, 8,
G_PARAM_READWRITE); G_PARAM_READWRITE);
gimp_procedure_add_int_argument (procedure, "speed", gimp_procedure_add_choice_argument (procedure, "speed",
_("Effort/S_peed"), _("Effort/S_peed"),
_("Encoder effort setting"), _("Encoder effort setting"),
1, 9, gimp_choice_new_with_values ("lightning", 1, _("lightning (fastest)"), NULL,
7, "thunder", 2, _("thunder"), NULL,
G_PARAM_READWRITE); "falcon", 3, _("falcon (faster)"), NULL,
"cheetah", 4, _("cheetah"), NULL,
"hare", 5, _("hare"), NULL,
"wombat", 6, _("wombat"), NULL,
"squirrel", 7, _("squirrel"), NULL,
"kitten", 8, _("kitten"), NULL,
"tortoise", 9, _("tortoise (slower)"), NULL,
NULL),
"squirrel",
G_PARAM_READWRITE);
gimp_procedure_add_boolean_argument (procedure, "uses-original-profile", gimp_procedure_add_boolean_argument (procedure, "uses-original-profile",
_("Save ori_ginal profile"), _("Save ori_ginal profile"),
@ -1399,13 +1408,14 @@ export_image (GFile *file,
g_object_get (config, g_object_get (config,
"lossless", &lossless, "lossless", &lossless,
"compression", &compression, "compression", &compression,
"speed", &speed,
"save-bit-depth", &bit_depth, "save-bit-depth", &bit_depth,
"cmyk", &cmyk, "cmyk", &cmyk,
"uses-original-profile", &uses_original_profile, "uses-original-profile", &uses_original_profile,
"save-exif", &save_exif, "save-exif", &save_exif,
"save-xmp", &save_xmp, "save-xmp", &save_xmp,
NULL); NULL);
speed = gimp_procedure_config_get_choice_id (GIMP_PROCEDURE_CONFIG (config),
"speed");
if (lossless || cmyk) if (lossless || cmyk)
{ {
@ -2025,20 +2035,6 @@ save_dialog (GimpImage *image,
G_BINDING_SYNC_CREATE | G_BINDING_SYNC_CREATE |
G_BINDING_INVERT_BOOLEAN); G_BINDING_INVERT_BOOLEAN);
store = gimp_int_store_new (_("lightning (fastest)"), 1,
_("thunder"), 2,
_("falcon (faster)"), 3,
_("cheetah"), 4,
_("hare"), 5,
_("wombat"), 6,
_("squirrel"), 7,
_("kitten"), 8,
_("tortoise (slower)"), 9,
NULL);
gimp_procedure_dialog_get_int_combo (GIMP_PROCEDURE_DIALOG (dialog),
"speed", GIMP_INT_STORE (store));
store = gimp_int_store_new (_("8 bit/channel"), 8, store = gimp_int_store_new (_("8 bit/channel"), 8,
_("16 bit/channel"), 16, _("16 bit/channel"), 16,
NULL); NULL);

View File

@ -319,20 +319,25 @@ mng_create_procedure (GimpPlugIn *plug_in,
1, G_MAXINT, 100, 1, G_MAXINT, 100,
G_PARAM_READWRITE); G_PARAM_READWRITE);
gimp_procedure_add_int_argument (procedure, "default-chunks", gimp_procedure_add_choice_argument (procedure, "default-chunks",
_("Default chunks t_ype"), _("Default chunks t_ype"),
_("(ANIMATED MNG) Default chunks type " _("(ANIMATED MNG) Default chunks type"),
"(0 = PNG + Delta PNG; 1 = JNG + Delta PNG; " gimp_choice_new_with_values ("png-delta", CHUNKS_PNG_D, _("PNG + delta PNG"), NULL,
"2 = All PNG; 3 = All JNG)"), "jng-delta", CHUNKS_JNG_D, _("JNG + delta PNG"), NULL,
0, 3, CHUNKS_PNG_D, "all-png", CHUNKS_PNG, _("All PNG"), NULL,
G_PARAM_READWRITE); "all-jng", CHUNKS_JNG, _("All JNG"), NULL,
NULL),
"png-delta",
G_PARAM_READWRITE);
gimp_procedure_add_int_argument (procedure, "default-dispose", gimp_procedure_add_choice_argument (procedure, "default-dispose",
_("De_fault frame disposal"), _("De_fault frame disposal"),
_("(ANIMATED MNG) Default dispose type " _("(ANIMATED MNG) Default dispose type"),
"(0 = combine; 1 = replace)"), gimp_choice_new_with_values ("combine", DISPOSE_COMBINE, _("Combine"), NULL,
0, 1, DISPOSE_COMBINE, "replace", DISPOSE_REPLACE, _("Replace"), NULL,
G_PARAM_READWRITE); NULL),
"combine",
G_PARAM_READWRITE);
gimp_procedure_add_boolean_argument (procedure, "bkgd", gimp_procedure_add_boolean_argument (procedure, "bkgd",
_("Save _background color"), _("Save _background color"),
@ -807,13 +812,17 @@ mng_export_image (GFile *file,
"jpeg-smoothing", &config_jpeg_smoothing, "jpeg-smoothing", &config_jpeg_smoothing,
"loop", &config_loop, "loop", &config_loop,
"default-delay", &config_default_delay, "default-delay", &config_default_delay,
"default-chunks", &config_default_chunks,
"default-dispose", &config_default_dispose,
"bkgd", &config_bkgd, "bkgd", &config_bkgd,
"gama", &config_gama, "gama", &config_gama,
"phys", &config_phys, "phys", &config_phys,
"time", &config_time, "time", &config_time,
NULL); NULL);
config_default_dispose =
gimp_procedure_config_get_choice_id (GIMP_PROCEDURE_CONFIG (config),
"default-dispose");
config_default_chunks =
gimp_procedure_config_get_choice_id (GIMP_PROCEDURE_CONFIG (config),
"default-chunks");
layers = gimp_image_get_layers (image, &num_layers); layers = gimp_image_get_layers (image, &num_layers);
@ -1566,15 +1575,14 @@ mng_save_dialog (GimpImage *image,
GimpProcedure *procedure, GimpProcedure *procedure,
GObject *config) GObject *config)
{ {
GtkWidget *dialog; GtkWidget *dialog;
GtkWidget *frame; GtkWidget *frame;
GtkWidget *hbox; GtkWidget *hbox;
GtkListStore *store; GtkWidget *combo;
GtkWidget *combo; GtkWidget *label;
GtkWidget *label; GtkWidget *scale;
GtkWidget *scale; gint num_layers;
gint num_layers; gboolean run;
gboolean run;
dialog = gimp_export_procedure_dialog_new (GIMP_EXPORT_PROCEDURE (procedure), dialog = gimp_export_procedure_dialog_new (GIMP_EXPORT_PROCEDURE (procedure),
GIMP_PROCEDURE_CONFIG (config), GIMP_PROCEDURE_CONFIG (config),
@ -1594,27 +1602,25 @@ mng_save_dialog (GimpImage *image,
g_free (gimp_image_get_layers (image, &num_layers)); g_free (gimp_image_get_layers (image, &num_layers));
if (num_layers == 1) if (num_layers == 1)
store = gimp_int_store_new (_("PNG"), CHUNKS_PNG_D, {
_("JNG"), CHUNKS_JNG_D, GimpParamSpecChoice *cspec;
NULL);
else
store = gimp_int_store_new (_("PNG + delta PNG"), CHUNKS_PNG_D,
_("JNG + delta PNG"), CHUNKS_JNG_D,
_("All PNG"), CHUNKS_PNG,
_("All JNG"), CHUNKS_JNG,
NULL);
combo = gimp_procedure_dialog_get_int_combo (GIMP_PROCEDURE_DIALOG (dialog), cspec =
"default-chunks", GIMP_PARAM_SPEC_CHOICE (g_object_class_find_property (G_OBJECT_GET_CLASS (config),
GIMP_INT_STORE (store)); "default-chunks"));
gimp_choice_set_sensitive (cspec->choice, "all-png", FALSE);
gimp_choice_set_sensitive (cspec->choice, "all-jng", FALSE);
}
combo = gimp_procedure_dialog_get_widget (GIMP_PROCEDURE_DIALOG (dialog),
"default-chunks",
G_TYPE_NONE);
gtk_widget_set_margin_bottom (combo, 6); gtk_widget_set_margin_bottom (combo, 6);
store = gimp_int_store_new (_("Combine"), DISPOSE_COMBINE, combo = gimp_procedure_dialog_get_widget (GIMP_PROCEDURE_DIALOG (dialog),
_("Replace"), DISPOSE_REPLACE, "default-dispose",
NULL); G_TYPE_NONE);
combo = gimp_procedure_dialog_get_int_combo (GIMP_PROCEDURE_DIALOG (dialog),
"default-dispose",
GIMP_INT_STORE (store));
gtk_widget_set_margin_bottom (combo, 6); gtk_widget_set_margin_bottom (combo, 6);
scale = gimp_procedure_dialog_get_scale_entry (GIMP_PROCEDURE_DIALOG (dialog), scale = gimp_procedure_dialog_get_scale_entry (GIMP_PROCEDURE_DIALOG (dialog),

View File

@ -316,11 +316,14 @@ tga_create_procedure (GimpPlugIn *plug_in,
TRUE, TRUE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
gimp_procedure_add_int_argument (procedure, "origin", gimp_procedure_add_choice_argument (procedure, "origin",
_("Ori_gin"), _("Ori_gin"),
_("Image origin (0 = top-left, 1 = bottom-left)"), _("Image origin"),
0, 1, ORIGIN_BOTTOM_LEFT, gimp_choice_new_with_values ("bottom-left", ORIGIN_BOTTOM_LEFT, _("Bottom left"), NULL,
G_PARAM_READWRITE); "top-left", ORIGIN_TOP_LEFT, _("Top left"), NULL,
NULL),
"bottom-left",
G_PARAM_READWRITE);
} }
return procedure; return procedure;
@ -1199,9 +1202,10 @@ export_image (GFile *file,
TgaOrigin origin; TgaOrigin origin;
g_object_get (config, g_object_get (config,
"rle", &rle, "rle", &rle,
"origin", &origin,
NULL); NULL);
origin = gimp_procedure_config_get_choice_id (GIMP_PROCEDURE_CONFIG (config),
"origin");
buffer = gimp_drawable_get_buffer (drawable); buffer = gimp_drawable_get_buffer (drawable);
@ -1425,7 +1429,6 @@ save_dialog (GimpImage *image,
GObject *config) GObject *config)
{ {
GtkWidget *dialog; GtkWidget *dialog;
GtkListStore *store;
GtkWidget *vbox; GtkWidget *vbox;
gboolean run; gboolean run;
@ -1433,12 +1436,6 @@ save_dialog (GimpImage *image,
GIMP_PROCEDURE_CONFIG (config), GIMP_PROCEDURE_CONFIG (config),
image); image);
store = gimp_int_store_new (_("Bottom left"), ORIGIN_BOTTOM_LEFT,
_("Top left"), ORIGIN_TOP_LEFT,
NULL);
gimp_procedure_dialog_get_int_combo (GIMP_PROCEDURE_DIALOG (dialog),
"origin", GIMP_INT_STORE (store));
vbox = gimp_procedure_dialog_fill_box (GIMP_PROCEDURE_DIALOG (dialog), vbox = gimp_procedure_dialog_fill_box (GIMP_PROCEDURE_DIALOG (dialog),
"tga-save-vbox", "tga-save-vbox",
"rle", "rle",

View File

@ -42,17 +42,6 @@
#include "libgimp/stdplugins-intl.h" #include "libgimp/stdplugins-intl.h"
typedef enum
{
RGB_565,
RGBA_5551,
RGB_555,
RGB_888,
RGBA_8888,
RGBX_8888
} RGBMode;
static void write_image (FILE *f, static void write_image (FILE *f,
guchar *src, guchar *src,
gint width, gint width,
@ -167,7 +156,7 @@ export_image (GFile *file,
if (run_mode == GIMP_RUN_INTERACTIVE) if (run_mode == GIMP_RUN_INTERACTIVE)
g_object_set (config, g_object_set (config,
"rgb-format", RGBA_8888, "rgb-format", "rgba-8888",
"use-rle", FALSE, "use-rle", FALSE,
NULL); NULL);
else else
@ -185,7 +174,7 @@ export_image (GFile *file,
if (run_mode == GIMP_RUN_INTERACTIVE) if (run_mode == GIMP_RUN_INTERACTIVE)
g_object_set (config, g_object_set (config,
"rgb-format", RGB_888, "rgb-format", "rgb-888",
"use-rle", FALSE, "use-rle", FALSE,
NULL); NULL);
else else
@ -289,9 +278,9 @@ export_image (GFile *file,
return GIMP_PDB_CANCEL; return GIMP_PDB_CANCEL;
} }
g_object_get (config, rgb_format =
"rgb-format", &rgb_format, gimp_procedure_config_get_choice_id (GIMP_PROCEDURE_CONFIG (config),
NULL); "rgb-format");
/* mask_info_size is only set to non-zero for 16- and 32-bpp */ /* mask_info_size is only set to non-zero for 16- and 32-bpp */
switch (rgb_format) switch (rgb_format)
@ -327,8 +316,10 @@ export_image (GFile *file,
g_object_get (config, g_object_get (config,
"use-rle", &use_rle, "use-rle", &use_rle,
"write-color-space", &write_color_space, "write-color-space", &write_color_space,
"rgb-format", &rgb_format,
NULL); NULL);
rgb_format =
gimp_procedure_config_get_choice_id (GIMP_PROCEDURE_CONFIG (config),
"rgb-format");
gimp_progress_init_printf (_("Exporting '%s'"), gimp_progress_init_printf (_("Exporting '%s'"),
gimp_file_get_utf8_name (file)); gimp_file_get_utf8_name (file));
@ -931,9 +922,8 @@ format_sensitive_callback (GObject *config,
gint value; gint value;
gint channels = GPOINTER_TO_INT (data); gint channels = GPOINTER_TO_INT (data);
g_object_get (config, value = gimp_procedure_config_get_choice_id (GIMP_PROCEDURE_CONFIG (config),
"rgb-format", &value, "rgb-format");
NULL);
switch (value) switch (value)
{ {
@ -954,9 +944,8 @@ config_notify (GObject *config,
gint channels = GPOINTER_TO_INT (data); gint channels = GPOINTER_TO_INT (data);
RGBMode format; RGBMode format;
g_object_get (config, format = gimp_procedure_config_get_choice_id (GIMP_PROCEDURE_CONFIG (config),
"rgb-format", &format, "rgb-format");
NULL);
switch (format) switch (format)
{ {
@ -966,7 +955,10 @@ config_notify (GObject *config,
{ {
g_signal_handlers_block_by_func (config, config_notify, data); g_signal_handlers_block_by_func (config, config_notify, data);
g_object_set (config, "rgb-format", format - 1, NULL); if (format == RGBA_5551)
g_object_set (config, "rgb-format", "rgb-565", NULL);
else if (format == RGBA_8888)
g_object_set (config, "rgb-format", "rgb-888", NULL);
g_signal_handlers_unblock_by_func (config, config_notify, data); g_signal_handlers_unblock_by_func (config, config_notify, data);
} }
@ -984,13 +976,12 @@ save_dialog (GimpProcedure *procedure,
gint channels, gint channels,
gint bpp) gint bpp)
{ {
GtkWidget *dialog; GtkWidget *dialog;
GtkWidget *toggle; GtkWidget *toggle;
GtkWidget *vbox; GtkWidget *vbox;
GtkWidget *combo; GtkWidget *combo;
GtkListStore *store; gboolean is_format_sensitive;
gboolean is_format_sensitive; gboolean run;
gboolean run;
dialog = gimp_export_procedure_dialog_new (GIMP_EXPORT_PROCEDURE (procedure), dialog = gimp_export_procedure_dialog_new (GIMP_EXPORT_PROCEDURE (procedure),
GIMP_PROCEDURE_CONFIG (config), GIMP_PROCEDURE_CONFIG (config),
@ -1023,16 +1014,8 @@ save_dialog (GimpProcedure *procedure,
FALSE, "write-color-space"); FALSE, "write-color-space");
/* RGB Encoding Options */ /* RGB Encoding Options */
store = gimp_int_store_new (_("16 bit (R5 G6 B5)"), RGB_565, combo = gimp_procedure_dialog_get_widget (GIMP_PROCEDURE_DIALOG (dialog),
_("16 bit (A1 R5 G5 B5)"), RGBA_5551, "rgb-format", G_TYPE_NONE);
_("16 bit (X1 R5 G5 B5)"), RGB_555,
_("24 bit (R8 G8 B8)"), RGB_888,
_("32 bit (A8 R8 G8 B8)"), RGBA_8888,
_("32 bit (X8 R8 G8 B8)"), RGBX_8888,
NULL);
combo = gimp_procedure_dialog_get_int_combo (GIMP_PROCEDURE_DIALOG (dialog),
"rgb-format",
GIMP_INT_STORE (store));
g_object_set (combo, "margin", 12, NULL); g_object_set (combo, "margin", 12, NULL);
/* Determine if RGB Format combo should be initially sensitive */ /* Determine if RGB Format combo should be initially sensitive */

View File

@ -20,6 +20,17 @@
#define __BMP_EXPORT_H__ #define __BMP_EXPORT_H__
typedef enum
{
RGB_565,
RGBA_5551,
RGB_555,
RGB_888,
RGBA_8888,
RGBX_8888
} RGBMode;
GimpPDBStatusType export_image (GFile *file, GimpPDBStatusType export_image (GFile *file,
GimpImage *image, GimpImage *image,
GimpDrawable *drawable, GimpDrawable *drawable,

View File

@ -216,13 +216,18 @@ bmp_create_procedure (GimpPlugIn *plug_in,
TRUE, TRUE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
gimp_procedure_add_int_argument (procedure, "rgb-format", gimp_procedure_add_choice_argument (procedure, "rgb-format",
_("R_GB format"), _("R_GB format"),
_("Export format for RGB images " _("Export format for RGB images"),
"(0=RGB_565, 1=RGBA_5551, 2=RGB_555, 3=RGB_888, " gimp_choice_new_with_values ("rgb-565", RGB_565, _("16 bit (R5 G6 B5)"), NULL,
"4=RGBA_8888, 5=RGBX_8888)"), "rgba-5551", RGBA_5551, _("16 bit (A1 R5 G5 B5)"), NULL,
0, 5, 3, "rgb-555", RGB_555, _("16 bit (X1 R5 G5 B5)"), NULL,
G_PARAM_READWRITE); "rgb-888", RGB_888, _("24 bit (R8 G8 B8)"), NULL,
"rgba-8888", RGBA_8888, _("32 bit (A8 R8 G8 B8)"), NULL,
"rgbx-8888", RGBX_8888, _("32 bit (X8 R8 G8 B8"), NULL,
NULL),
"rgb-888",
G_PARAM_READWRITE);
} }
return procedure; return procedure;

View File

@ -196,11 +196,15 @@ sgi_create_procedure (GimpPlugIn *plug_in,
GIMP_EXPORT_CAN_HANDLE_ALPHA, GIMP_EXPORT_CAN_HANDLE_ALPHA,
NULL, NULL, NULL); NULL, NULL, NULL);
gimp_procedure_add_int_argument (procedure, "compression", gimp_procedure_add_choice_argument (procedure, "compression",
_("Compression _type"), _("Compression _type"),
_("Compression level (0 = none, 1 = RLE, 2 = ARLE)"), _("Compression level"),
0, 2, SGI_COMP_RLE, gimp_choice_new_with_values ("none", SGI_COMP_NONE, _("No compression"), NULL,
GIMP_PARAM_READWRITE); "rle", SGI_COMP_RLE, _("RLE compression"), NULL,
"arle", SGI_COMP_ARLE, _("Aggressive RLE (not supported by SGI)"), NULL,
NULL),
"rle",
G_PARAM_READWRITE);
} }
return procedure; return procedure;
@ -574,9 +578,9 @@ export_image (GFile *file,
guchar *pptr; /* Current pixel */ guchar *pptr; /* Current pixel */
gushort **rows; /* SGI image data */ gushort **rows; /* SGI image data */
g_object_get (config, compression =
"compression", &compression, gimp_procedure_config_get_choice_id (GIMP_PROCEDURE_CONFIG (config),
NULL); "compression");
/* /*
* Get the drawable for the current image... * Get the drawable for the current image...
@ -709,25 +713,14 @@ save_dialog (GimpProcedure *procedure,
GObject *config, GObject *config,
GimpImage *image) GimpImage *image)
{ {
GtkWidget *dialog; GtkWidget *dialog;
GtkWidget *vbox; GtkWidget *vbox;
GtkListStore *store; gboolean run;
gboolean run;
dialog = gimp_export_procedure_dialog_new (GIMP_EXPORT_PROCEDURE (procedure), dialog = gimp_export_procedure_dialog_new (GIMP_EXPORT_PROCEDURE (procedure),
GIMP_PROCEDURE_CONFIG (config), GIMP_PROCEDURE_CONFIG (config),
image); image);
store = gimp_int_store_new (_("No compression"),
SGI_COMP_NONE,
_("RLE compression"),
SGI_COMP_RLE,
_("Aggressive RLE (not supported by SGI)"),
SGI_COMP_ARLE,
NULL);
gimp_procedure_dialog_get_int_combo (GIMP_PROCEDURE_DIALOG (dialog),
"compression", GIMP_INT_STORE (store));
vbox = gimp_procedure_dialog_fill_box (GIMP_PROCEDURE_DIALOG (dialog), vbox = gimp_procedure_dialog_fill_box (GIMP_PROCEDURE_DIALOG (dialog),
"sgi-vbox", "compression", NULL); "sgi-vbox", "compression", NULL);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);

View File

@ -62,11 +62,10 @@ save_dialog (GimpImage *image,
GimpProcedure *procedure, GimpProcedure *procedure,
GObject *config) GObject *config)
{ {
GtkWidget *dialog; GtkWidget *dialog;
GtkListStore *store; gint32 nlayers;
gint32 nlayers; gboolean animation_supported = FALSE;
gboolean animation_supported = FALSE; gboolean run;
gboolean run;
g_free (gimp_image_get_layers (image, &nlayers)); g_free (gimp_image_get_layers (image, &nlayers));
@ -76,17 +75,6 @@ save_dialog (GimpImage *image,
GIMP_PROCEDURE_CONFIG (config), GIMP_PROCEDURE_CONFIG (config),
image); image);
/* Create the combobox containing the presets */
store = gimp_int_store_new (_("Default"), WEBP_PRESET_DEFAULT,
_("Picture"), WEBP_PRESET_PICTURE,
_("Photo"), WEBP_PRESET_PHOTO,
_("Drawing"), WEBP_PRESET_DRAWING,
_("Icon"), WEBP_PRESET_ICON,
_("Text"), WEBP_PRESET_TEXT,
NULL);
gimp_procedure_dialog_get_int_combo (GIMP_PROCEDURE_DIALOG (dialog),
"preset", GIMP_INT_STORE (store));
/* Create scale for image and alpha quality */ /* Create scale for image and alpha quality */
gimp_procedure_dialog_get_widget (GIMP_PROCEDURE_DIALOG (dialog), gimp_procedure_dialog_get_widget (GIMP_PROCEDURE_DIALOG (dialog),
"quality", GIMP_TYPE_SPIN_SCALE); "quality", GIMP_TYPE_SPIN_SCALE);

View File

@ -161,12 +161,13 @@ save_layer (GFile *file,
gboolean use_sharp_yuv; gboolean use_sharp_yuv;
g_object_get (config, g_object_get (config,
"preset", &preset,
"lossless", &lossless, "lossless", &lossless,
"quality", &quality, "quality", &quality,
"alpha-quality", &alpha_quality, "alpha-quality", &alpha_quality,
"use-sharp-yuv", &use_sharp_yuv, "use-sharp-yuv", &use_sharp_yuv,
NULL); NULL);
preset = gimp_procedure_config_get_choice_id (GIMP_PROCEDURE_CONFIG (config),
"preset");
webp_decide_output (image, config, &profile, &out_linear); webp_decide_output (image, config, &profile, &out_linear);
if (profile) if (profile)
@ -543,18 +544,19 @@ save_animation (GFile *file,
g_return_val_if_fail (n_drawables > 0, FALSE); g_return_val_if_fail (n_drawables > 0, FALSE);
g_object_get (config, g_object_get (config,
"preset", &preset, "lossless", &lossless,
"lossless", &lossless, "animation", &animation,
"animation", &animation, "animation-loop", &loop,
"animation-loop", &loop, "minimize-size", &minimize_size,
"minimize-size", &minimize_size, "keyframe-distance", &keyframe_distance,
"keyframe-distance", &keyframe_distance, "quality", &quality,
"quality", &quality, "alpha-quality", &alpha_quality,
"alpha-quality", &alpha_quality, "default-delay", &default_delay,
"default-delay", &default_delay, "force-delay", &force_delay,
"force-delay", &force_delay, "use-sharp-yuv", &use_sharp_yuv,
"use-sharp-yuv", &use_sharp_yuv,
NULL); NULL);
preset = gimp_procedure_config_get_choice_id (GIMP_PROCEDURE_CONFIG (config),
"preset");
layers = gimp_image_list_layers (image); layers = gimp_image_list_layers (image);

View File

@ -154,8 +154,8 @@ webp_create_procedure (GimpPlugIn *plug_in,
gimp_procedure_set_menu_label (procedure, _("WebP image")); gimp_procedure_set_menu_label (procedure, _("WebP image"));
gimp_procedure_set_documentation (procedure, gimp_procedure_set_documentation (procedure,
"Saves files in the WebP image format", _("Saves files in the WebP image format"),
"Saves files in the WebP image format", _("Saves files in the WebP image format"),
name); name);
gimp_procedure_set_attribution (procedure, gimp_procedure_set_attribution (procedure,
"Nathan Osman, Ben Touchette", "Nathan Osman, Ben Touchette",
@ -177,12 +177,18 @@ webp_create_procedure (GimpPlugIn *plug_in,
GIMP_EXPORT_CAN_HANDLE_ALPHA, GIMP_EXPORT_CAN_HANDLE_ALPHA,
export_edit_options, NULL, NULL); export_edit_options, NULL, NULL);
gimp_procedure_add_int_argument (procedure, "preset", gimp_procedure_add_choice_argument (procedure, "preset",
_("Source _type"), _("Source _type"),
_("WebP encoder preset (Default=0, Picture=1, Photo=2, Drawing=3, " _("WebP encoder preset"),
"Icon=4, Text=5)"), gimp_choice_new_with_values ("default", WEBP_PRESET_DEFAULT, _("Default"), NULL,
0, 5, WEBP_PRESET_DEFAULT, "picture", WEBP_PRESET_PICTURE, _("Picture"), NULL,
G_PARAM_READWRITE); "photo", WEBP_PRESET_PHOTO, _("Photo"), NULL,
"drawing", WEBP_PRESET_DRAWING, _("Drawing"), NULL,
"icon", WEBP_PRESET_ICON, _("Icon"), NULL,
"text", WEBP_PRESET_TEXT, _("Text"), NULL,
NULL),
"default",
G_PARAM_READWRITE);
gimp_procedure_add_boolean_argument (procedure, "lossless", gimp_procedure_add_boolean_argument (procedure, "lossless",
_("L_ossless"), _("L_ossless"),