mirror of https://github.com/GNOME/gimp.git
plug-ins: Port file-jpeg to GimpChoice parameters
This commit is contained in:
parent
20b19b960e
commit
62cdbfbafa
|
@ -244,10 +244,8 @@ export_image (GFile *file,
|
|||
"optimize", &optimize,
|
||||
"progressive", &progressive,
|
||||
"cmyk", &cmyk,
|
||||
"sub-sampling", &subsmp,
|
||||
"baseline", &baseline,
|
||||
"restart", &restart,
|
||||
"dct", &dct,
|
||||
|
||||
/* Original quality settings. */
|
||||
"use-original-quality", &use_orig_quality,
|
||||
|
@ -261,6 +259,8 @@ export_image (GFile *file,
|
|||
"gimp-comment", &comment,
|
||||
|
||||
NULL);
|
||||
dct = gimp_procedure_config_get_choice_id (config, "dct");
|
||||
subsmp = gimp_procedure_config_get_choice_id (config, "sub-sampling");
|
||||
|
||||
quality = (gint) (dquality * 100.0 + 0.5);
|
||||
|
||||
|
@ -843,7 +843,6 @@ save_dialog (GimpProcedure *procedure,
|
|||
GtkWidget *dialog;
|
||||
GtkWidget *widget;
|
||||
GtkWidget *profile_label;
|
||||
GtkListStore *store;
|
||||
GimpColorProfile *cmyk_profile = NULL;
|
||||
gint orig_quality;
|
||||
gint restart;
|
||||
|
@ -939,33 +938,15 @@ save_dialog (GimpProcedure *procedure,
|
|||
NULL);
|
||||
|
||||
/* Subsampling */
|
||||
store = gimp_int_store_new (_("4:4:4 (best quality)"),
|
||||
JPEG_SUBSAMPLING_1x1_1x1_1x1,
|
||||
_("4:2:2 (chroma halved horizontally)"),
|
||||
JPEG_SUBSAMPLING_2x1_1x1_1x1,
|
||||
_("4:4:0 (chroma halved vertically)"),
|
||||
JPEG_SUBSAMPLING_1x2_1x1_1x1,
|
||||
_("4:2:0 (chroma quartered)"),
|
||||
JPEG_SUBSAMPLING_2x2_1x1_1x1,
|
||||
NULL);
|
||||
widget = gimp_procedure_dialog_get_int_combo (GIMP_PROCEDURE_DIALOG (dialog),
|
||||
"sub-sampling", GIMP_INT_STORE (store));
|
||||
widget = gimp_label_int_widget_get_widget (GIMP_LABEL_INT_WIDGET (widget));
|
||||
widget = gimp_procedure_dialog_get_widget (GIMP_PROCEDURE_DIALOG (dialog),
|
||||
"sub-sampling", G_TYPE_NONE);
|
||||
|
||||
if (! gimp_drawable_is_rgb (drawable))
|
||||
{
|
||||
g_object_set (config, "sub-sampling", JPEG_SUBSAMPLING_1x1_1x1_1x1, NULL);
|
||||
g_object_set (config, "sub-sampling", "sub-sampling-1x1", NULL);
|
||||
gtk_widget_set_sensitive (widget, FALSE);
|
||||
}
|
||||
|
||||
/* DCT method */
|
||||
store = gimp_int_store_new (_("Fast Integer"), 1,
|
||||
_("Integer"), 0,
|
||||
_("Floating-Point"), 2,
|
||||
NULL);
|
||||
gimp_procedure_dialog_get_int_combo (GIMP_PROCEDURE_DIALOG (dialog),
|
||||
"dct", GIMP_INT_STORE (store));
|
||||
|
||||
gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
|
||||
"advanced-title", _("Advanced Options"),
|
||||
FALSE, FALSE);
|
||||
|
@ -1055,8 +1036,8 @@ subsampling_changed (GimpProcedureConfig *config,
|
|||
g_object_get (config,
|
||||
"use-original-quality", &use_orig_quality,
|
||||
"original-sub-sampling", &orig_subsmp,
|
||||
"sub-sampling", &subsmp,
|
||||
NULL);
|
||||
subsmp = gimp_procedure_config_get_choice_id (config, "sub-sampling");
|
||||
|
||||
/* smoothing is not supported with nonstandard sampling ratios */
|
||||
gtk_widget_set_sensitive (smoothing_scale,
|
||||
|
@ -1101,5 +1082,24 @@ use_orig_qual_changed_rgb (GimpProcedureConfig *config)
|
|||
|
||||
/* the test is (orig_quality > 0), not (orig_subsmp > 0) - this is normal */
|
||||
if (use_orig_quality && orig_quality > 0)
|
||||
g_object_set (config, "sub-sampling", orig_subsmp, NULL);
|
||||
{
|
||||
switch (orig_subsmp)
|
||||
{
|
||||
case JPEG_SUBSAMPLING_1x1_1x1_1x1:
|
||||
g_object_set (config, "sub-sampling", "sub-sampling-1x1", NULL);
|
||||
break;
|
||||
|
||||
case JPEG_SUBSAMPLING_2x1_1x1_1x1:
|
||||
g_object_set (config, "sub-sampling", "sub-sampling-2x1", NULL);
|
||||
break;
|
||||
|
||||
case JPEG_SUBSAMPLING_1x2_1x1_1x1:
|
||||
g_object_set (config, "sub-sampling", "sub-sampling-1x2", NULL);
|
||||
break;
|
||||
|
||||
case JPEG_SUBSAMPLING_2x2_1x1_1x1:
|
||||
g_object_set (config, "sub-sampling", "sub-sampling-2x2", NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,8 +136,8 @@ jpeg_create_procedure (GimpPlugIn *plug_in,
|
|||
gimp_procedure_set_menu_label (procedure, _("JPEG image"));
|
||||
|
||||
gimp_procedure_set_documentation (procedure,
|
||||
"Loads files in the JPEG file format",
|
||||
"Loads files in the JPEG file format",
|
||||
_("Loads files in the JPEG file format"),
|
||||
_("Loads files in the JPEG file format"),
|
||||
name);
|
||||
gimp_procedure_set_attribution (procedure,
|
||||
"Spencer Kimball, Peter Mattis & others",
|
||||
|
@ -161,9 +161,9 @@ jpeg_create_procedure (GimpPlugIn *plug_in,
|
|||
jpeg_load_thumb, NULL, NULL);
|
||||
|
||||
gimp_procedure_set_documentation (procedure,
|
||||
"Loads a thumbnail from a JPEG image",
|
||||
"Loads a thumbnail from a JPEG image, "
|
||||
"if one exists",
|
||||
_("Loads a thumbnail from a JPEG image"),
|
||||
_("Loads a thumbnail from a JPEG image, "
|
||||
"if one exists"),
|
||||
name);
|
||||
gimp_procedure_set_attribution (procedure,
|
||||
"Mukund Sivaraman <muks@mukund.org>, "
|
||||
|
@ -183,9 +183,9 @@ jpeg_create_procedure (GimpPlugIn *plug_in,
|
|||
gimp_procedure_set_menu_label (procedure, _("JPEG image"));
|
||||
|
||||
gimp_procedure_set_documentation (procedure,
|
||||
"Saves files in the JPEG file format",
|
||||
"Saves files in the lossy, widely "
|
||||
"supported JPEG format",
|
||||
_("Exports files in the JPEG file format"),
|
||||
_("Exports files in the lossy, widely "
|
||||
"supported JPEG format"),
|
||||
name);
|
||||
gimp_procedure_set_attribution (procedure,
|
||||
"Spencer Kimball, Peter Mattis & others",
|
||||
|
@ -232,16 +232,15 @@ jpeg_create_procedure (GimpPlugIn *plug_in,
|
|||
FALSE,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
GIMP_PROC_ARG_INT (procedure, "sub-sampling",
|
||||
_("Su_bsampling"),
|
||||
_("Sub-sampling type { 0 == 4:2:0 (chroma quartered), "
|
||||
"1 == 4:2:2 (chroma halved horizontally), "
|
||||
"2 == 4:4:4 (best quality), "
|
||||
"3 == 4:4:0 (chroma halved vertically)"),
|
||||
JPEG_SUBSAMPLING_2x2_1x1_1x1,
|
||||
JPEG_SUBSAMPLING_1x2_1x1_1x1,
|
||||
JPEG_SUBSAMPLING_1x1_1x1_1x1,
|
||||
G_PARAM_READWRITE);
|
||||
GIMP_PROC_ARG_CHOICE (procedure, "sub-sampling",
|
||||
_("Su_bsampling"),
|
||||
_("Sub-sampling type"),
|
||||
gimp_choice_new_with_values ("sub-sampling-1x1", JPEG_SUBSAMPLING_1x1_1x1_1x1, _("4:4:4 (best quality)"), NULL,
|
||||
"sub-sampling-2x1", JPEG_SUBSAMPLING_2x1_1x1_1x1, _("4:2:2 (chroma halved horizontally)"), NULL,
|
||||
"sub-sampling-1x2", JPEG_SUBSAMPLING_1x2_1x1_1x1, _("4:4:0 (chroma halved vertically)"), NULL,
|
||||
"sub-sampling-2x2", JPEG_SUBSAMPLING_2x2_1x1_1x1, _("4:2:0 (chroma quartered)"), NULL,
|
||||
NULL),
|
||||
"sub-sampling-1x1", G_PARAM_READWRITE);
|
||||
|
||||
GIMP_PROC_ARG_BOOLEAN (procedure, "baseline",
|
||||
_("Baseline"),
|
||||
|
@ -257,12 +256,14 @@ jpeg_create_procedure (GimpPlugIn *plug_in,
|
|||
0, 64, 0,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
GIMP_PROC_ARG_INT (procedure, "dct",
|
||||
_("_DCT method"),
|
||||
_("DCT method to use { INTEGER (0), FIXED (1), "
|
||||
"FLOAT (2) }"),
|
||||
0, 2, 0,
|
||||
G_PARAM_READWRITE);
|
||||
GIMP_PROC_ARG_CHOICE (procedure, "dct",
|
||||
_("_DCT method"),
|
||||
_("DCT method to use"),
|
||||
gimp_choice_new_with_values ("fixed", 1, _("Fast Integer"), NULL,
|
||||
"integer", 0, _("Integer"), NULL,
|
||||
"float", 2, _("Floating-Point"), NULL,
|
||||
NULL),
|
||||
"integer", G_PARAM_READWRITE);
|
||||
|
||||
/* Some auxiliary arguments mostly for interactive usage. */
|
||||
|
||||
|
@ -502,9 +503,9 @@ jpeg_export (GimpProcedure *procedure,
|
|||
&orig_num_quant_tables);
|
||||
|
||||
g_object_get (config,
|
||||
"quality", &dquality,
|
||||
"sub-sampling", &subsmp,
|
||||
"quality", &dquality,
|
||||
NULL);
|
||||
subsmp = gimp_procedure_config_get_choice_id (config, "sub-sampling");
|
||||
|
||||
quality = (gint) (dquality * 100.0);
|
||||
|
||||
|
@ -528,7 +529,24 @@ jpeg_export (GimpProcedure *procedure,
|
|||
orig_subsmp == JPEG_SUBSAMPLING_2x2_1x1_1x1))
|
||||
{
|
||||
subsmp = orig_subsmp;
|
||||
g_object_set (config, "sub-sampling", orig_subsmp, NULL);
|
||||
switch (subsmp)
|
||||
{
|
||||
case JPEG_SUBSAMPLING_1x1_1x1_1x1:
|
||||
g_object_set (config, "sub-sampling", "sub-sampling-1x1", NULL);
|
||||
break;
|
||||
|
||||
case JPEG_SUBSAMPLING_2x1_1x1_1x1:
|
||||
g_object_set (config, "sub-sampling", "sub-sampling-2x1", NULL);
|
||||
break;
|
||||
|
||||
case JPEG_SUBSAMPLING_1x2_1x1_1x1:
|
||||
g_object_set (config, "sub-sampling", "sub-sampling-1x2", NULL);
|
||||
break;
|
||||
|
||||
case JPEG_SUBSAMPLING_2x2_1x1_1x1:
|
||||
g_object_set (config, "sub-sampling", "sub-sampling-2x2", NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (orig_quality == quality && orig_subsmp == subsmp)
|
||||
|
|
Loading…
Reference in New Issue