plug-ins: port compose to gimp_image_procedure_new2()

Converted to GimpProcedureDialog as well, and changed the
string argument for the combobox to GimpChoice.
Some widgets are still standalone and could be further improved
to work with GimpProcedureDialog.
This commit is contained in:
Alx Sa 2023-09-04 04:54:36 +00:00 committed by Jehan
parent b7bff4ee9a
commit 7b29ac247a

View file

@ -139,56 +139,58 @@ static GimpValueArray * compose_run (GimpProcedure *procedur
GimpImage *image, GimpImage *image,
gint n_drawables, gint n_drawables,
GimpDrawable **drawables, GimpDrawable **drawables,
const GimpValueArray *args, GimpProcedureConfig *config,
gpointer run_data); gpointer run_data);
static void cpn_affine_transform (GeglBuffer *buffer, static void cpn_affine_transform (GeglBuffer *buffer,
gdouble min, gdouble min,
gdouble max); gdouble max);
static void fill_buffer_from_components (GeglBuffer *temp[MAX_COMPOSE_IMAGES], static void fill_buffer_from_components (GeglBuffer *temp[MAX_COMPOSE_IMAGES],
GeglBuffer *dst, GeglBuffer *dst,
gint num_cpn, gint num_cpn,
ComposeInput *inputs, ComposeInput *inputs,
gdouble mask_vals[MAX_COMPOSE_IMAGES]); gdouble mask_vals[MAX_COMPOSE_IMAGES]);
static void perform_composition (COMPOSE_DSC curr_compose_dsc, static void perform_composition (COMPOSE_DSC curr_compose_dsc,
GeglBuffer *buffer_src[MAX_COMPOSE_IMAGES], GeglBuffer *buffer_src[MAX_COMPOSE_IMAGES],
GeglBuffer *buffer_dst, GeglBuffer *buffer_dst,
ComposeInput *inputs, ComposeInput *inputs,
gint num_images); gint num_images);
static GimpImage * compose (const gchar *compose_type, static GimpImage * compose (const gchar *compose_type,
ComposeInput *inputs, ComposeInput *inputs,
gboolean compose_by_drawable); gboolean compose_by_drawable,
GimpProcedureConfig *config);
static GimpImage * create_new_image (GFile *file, static GimpImage * create_new_image (GFile *file,
guint width, guint width,
guint height, guint height,
GimpImageType gdtype, GimpImageType gdtype,
GimpPrecision precision, GimpPrecision precision,
GimpLayer **layer, GimpLayer **layer,
GeglBuffer **buffer); GeglBuffer **buffer);
static gboolean compose_dialog (const gchar *compose_type, static gboolean compose_dialog (GimpProcedure *procedure,
GimpDrawable *drawable); GimpProcedureConfig *config,
const gchar *compose_type,
GimpDrawable *drawable);
static gboolean check_gray (GimpImage *image, static gboolean check_gray (GimpImage *image,
GimpItem *drawable, GimpItem *drawable,
gpointer data); gpointer data);
static void combo_callback (GimpIntComboBox *cbox, static void combo_callback (GimpIntComboBox *cbox,
gpointer data); gpointer data);
static void scale_callback (GimpLabelSpin *scale, static void scale_callback (GimpLabelSpin *scale,
ComposeInput *input); ComposeInput *input);
static void check_response (GtkWidget *dialog, static void check_response (GtkWidget *dialog,
gint response, gint response,
gpointer data); gpointer data);
static void type_combo_callback (GimpIntComboBox *combo, static void type_combo_callback (GimpProcedureConfig *config);
gpointer data);
G_DEFINE_TYPE (Compose, compose, GIMP_TYPE_PLUG_IN) G_DEFINE_TYPE (Compose, compose, GIMP_TYPE_PLUG_IN)
@ -388,9 +390,9 @@ compose_create_procedure (GimpPlugIn *plug_in,
if (! strcmp (name, COMPOSE_PROC)) if (! strcmp (name, COMPOSE_PROC))
{ {
procedure = gimp_image_procedure_new (plug_in, name, procedure = gimp_image_procedure_new2 (plug_in, name,
GIMP_PDB_PROC_TYPE_PLUGIN, GIMP_PDB_PROC_TYPE_PLUGIN,
compose_run, NULL, NULL); compose_run, NULL, NULL);
gimp_procedure_set_image_types (procedure, "GRAY*"); gimp_procedure_set_image_types (procedure, "GRAY*");
gimp_procedure_set_sensitivity_mask (procedure, gimp_procedure_set_sensitivity_mask (procedure,
@ -404,8 +406,8 @@ compose_create_procedure (GimpPlugIn *plug_in,
gimp_procedure_set_documentation (procedure, gimp_procedure_set_documentation (procedure,
_("Create an image using multiple " _("Create an image using multiple "
"gray images as color channels"), "gray images as color channels"),
"This function creates a new image from " _("This function creates a new image from "
"multiple gray images", "multiple gray images"),
name); name);
gimp_procedure_set_attribution (procedure, gimp_procedure_set_attribution (procedure,
"Peter Kirchgessner", "Peter Kirchgessner",
@ -413,50 +415,62 @@ compose_create_procedure (GimpPlugIn *plug_in,
"1997"); "1997");
GIMP_PROC_ARG_IMAGE (procedure, "image-2", GIMP_PROC_ARG_IMAGE (procedure, "image-2",
"Image 2", _("Image 2"),
"Second input image", _("Second input image"),
TRUE, TRUE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_IMAGE (procedure, "image-3", GIMP_PROC_ARG_IMAGE (procedure, "image-3",
"Image 3", _("Image 3"),
"Third input image", _("Third input image"),
TRUE, TRUE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_IMAGE (procedure, "image-4", GIMP_PROC_ARG_IMAGE (procedure, "image-4",
"Image 4", _("Image 4"),
"Fourth input image", _("Fourth input image"),
TRUE, TRUE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_STRING (procedure, "compose-type", GIMP_PROC_ARG_CHOICE (procedure, "compose-type",
"Compose type", _("Color _model"),
type_desc->str, type_desc->str,
"RGB", gimp_choice_new_with_values ("rgb", 0, _("RGB"), NULL,
"rgba", 1, _("RGBA"), NULL,
"hsv", 2, _("HSV"), NULL,
"hsl", 3, _("HSL"), NULL,
"cmyk", 4, _("CMYK"), NULL,
"lab", 5, _("LAB"), NULL,
"lch", 6, _("LCH"), NULL,
"ycbcr470", 7, _("YCbCr ITU R470"), NULL,
"ycbcr709", 8, _("YCbCr ITU R709"), NULL,
"ycbcr470f", 9, _("YCbCr ITU R470 256"), NULL,
"ycbcr709f", 10, _("YCbCr ITU R709 256"), NULL,
NULL),
"rgb",
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_VAL_IMAGE (procedure, "new-image", GIMP_PROC_VAL_IMAGE (procedure, "new-image",
"New image", _("New image"),
"Output image", _("Output image"),
FALSE, FALSE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
} }
else if (! strcmp (name, DRAWABLE_COMPOSE_PROC)) else if (! strcmp (name, DRAWABLE_COMPOSE_PROC))
{ {
procedure = gimp_image_procedure_new (plug_in, name, procedure = gimp_image_procedure_new2 (plug_in, name,
GIMP_PDB_PROC_TYPE_PLUGIN, GIMP_PDB_PROC_TYPE_PLUGIN,
compose_run, NULL, NULL); compose_run, NULL, NULL);
gimp_procedure_set_image_types (procedure, "GRAY*"); gimp_procedure_set_image_types (procedure, "GRAY*");
gimp_procedure_set_sensitivity_mask (procedure, gimp_procedure_set_sensitivity_mask (procedure,
GIMP_PROCEDURE_SENSITIVE_DRAWABLE); GIMP_PROCEDURE_SENSITIVE_DRAWABLE);
gimp_procedure_set_documentation (procedure, gimp_procedure_set_documentation (procedure,
"Compose an image from multiple " _("Compose an image from multiple "
"drawables of gray images", "drawables of gray images"),
"This function creates a new image from " _("This function creates a new image from "
"multiple drawables of gray images", "multiple drawables of gray images"),
name); name);
gimp_procedure_set_attribution (procedure, gimp_procedure_set_attribution (procedure,
"Peter Kirchgessner", "Peter Kirchgessner",
@ -464,40 +478,52 @@ compose_create_procedure (GimpPlugIn *plug_in,
"1998"); "1998");
GIMP_PROC_ARG_DRAWABLE (procedure, "drawable-2", GIMP_PROC_ARG_DRAWABLE (procedure, "drawable-2",
"Drawable 2", _("Drawable 2"),
"Second input drawable", _("Second input drawable"),
TRUE, TRUE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DRAWABLE (procedure, "drawable-3", GIMP_PROC_ARG_DRAWABLE (procedure, "drawable-3",
"Drawable 3", _("Drawable 3"),
"Third input drawable", _("Third input drawable"),
TRUE, TRUE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DRAWABLE (procedure, "drawable-4", GIMP_PROC_ARG_DRAWABLE (procedure, "drawable-4",
"Drawable 4", _("Drawable 4"),
"Fourth input drawable", _("Fourth input drawable"),
TRUE, TRUE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_STRING (procedure, "compose-type", GIMP_PROC_ARG_CHOICE (procedure, "compose-type",
"Compose type", _("Color _model"),
type_desc->str, type_desc->str,
"RGB", gimp_choice_new_with_values ("rgb", 0, _("RGB"), NULL,
"rgba", 1, _("RGBA"), NULL,
"hsv", 2, _("HSV"), NULL,
"hsl", 3, _("HSL"), NULL,
"cmyk", 4, _("CMYK"), NULL,
"lab", 5, _("LAB"), NULL,
"lch", 6, _("LCH"), NULL,
"ycbcr470", 7, _("YCbCr ITU R470"), NULL,
"ycbcr709", 8, _("YCbCr ITU R709"), NULL,
"ycbcr470f", 9, _("YCbCr ITU R470 256"), NULL,
"ycbcr709f", 10, _("YCbCr ITU R709 256"), NULL,
NULL),
"rgb",
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_VAL_IMAGE (procedure, "new-image", GIMP_PROC_VAL_IMAGE (procedure, "new-image",
"New image", _("New image"),
"Output image", _("Output image"),
FALSE, FALSE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
} }
else if (! strcmp (name, RECOMPOSE_PROC)) else if (! strcmp (name, RECOMPOSE_PROC))
{ {
procedure = gimp_image_procedure_new (plug_in, name, procedure = gimp_image_procedure_new2 (plug_in, name,
GIMP_PDB_PROC_TYPE_PLUGIN, GIMP_PDB_PROC_TYPE_PLUGIN,
compose_run, NULL, NULL); compose_run, NULL, NULL);
gimp_procedure_set_image_types (procedure, "GRAY*"); gimp_procedure_set_image_types (procedure, "GRAY*");
gimp_procedure_set_sensitivity_mask (procedure, gimp_procedure_set_sensitivity_mask (procedure,
@ -511,11 +537,11 @@ compose_create_procedure (GimpPlugIn *plug_in,
gimp_procedure_set_documentation (procedure, gimp_procedure_set_documentation (procedure,
_("Recompose an image that was " _("Recompose an image that was "
"previously decomposed"), "previously decomposed"),
"This function recombines the grayscale " _("This function recombines the grayscale "
"layers produced by Decompose " "layers produced by Decompose "
"into a single RGB or RGBA layer, and " "into a single RGB or RGBA layer, and "
"replaces the originally decomposed " "replaces the originally decomposed "
"layer with the result.", "layer with the result."),
name); name);
gimp_procedure_set_attribution (procedure, gimp_procedure_set_attribution (procedure,
"Bill Skaggs", "Bill Skaggs",
@ -534,13 +560,14 @@ compose_run (GimpProcedure *procedure,
GimpImage *image, GimpImage *image,
gint n_drawables, gint n_drawables,
GimpDrawable **drawables, GimpDrawable **drawables,
const GimpValueArray *args, GimpProcedureConfig *config,
gpointer run_data) gpointer run_data)
{ {
GimpValueArray *return_vals; GimpValueArray *return_vals;
GimpDrawable *drawable = NULL; GimpDrawable *drawable = NULL;
const gchar *name = gimp_procedure_get_name (procedure); const gchar *name = gimp_procedure_get_name (procedure);
gint compose_by_drawable; gint compose_by_drawable;
gint compose_idx;
gint i; gint i;
gegl_init (NULL, NULL); gegl_init (NULL, NULL);
@ -658,8 +685,6 @@ compose_run (GimpProcedure *procedure,
switch (run_mode) switch (run_mode)
{ {
case GIMP_RUN_INTERACTIVE: case GIMP_RUN_INTERACTIVE:
gimp_get_data (name, &composevals);
compose_by_drawable = TRUE; compose_by_drawable = TRUE;
/* Get a drawable-ID of the image */ /* Get a drawable-ID of the image */
@ -685,7 +710,8 @@ compose_run (GimpProcedure *procedure,
g_free (layers); g_free (layers);
} }
if (! compose_dialog (composevals.compose_type, drawable)) if (! compose_dialog (procedure, config, composevals.compose_type,
drawable))
return gimp_procedure_new_return_values (procedure, return gimp_procedure_new_return_values (procedure,
GIMP_PDB_CANCEL, GIMP_PDB_CANCEL,
NULL); NULL);
@ -695,21 +721,23 @@ compose_run (GimpProcedure *procedure,
if (compose_by_drawable) if (compose_by_drawable)
{ {
composevals.inputs[0].comp.object = drawable; composevals.inputs[0].comp.object = drawable;
composevals.inputs[1].comp.object = GIMP_VALUES_GET_DRAWABLE (args, 0);
composevals.inputs[2].comp.object = GIMP_VALUES_GET_DRAWABLE (args, 1); g_object_get (config,
composevals.inputs[3].comp.object = GIMP_VALUES_GET_DRAWABLE (args, 2); "drawable-2", &composevals.inputs[1].comp.object,
"drawable-3", &composevals.inputs[2].comp.object,
"drawable-4", &composevals.inputs[3].comp.object,
NULL);
} }
else else
{ {
composevals.inputs[0].comp.object = image; composevals.inputs[0].comp.object = image;
composevals.inputs[1].comp.object = GIMP_VALUES_GET_IMAGE (args, 0);
composevals.inputs[2].comp.object = GIMP_VALUES_GET_IMAGE (args, 1);
composevals.inputs[3].comp.object = GIMP_VALUES_GET_IMAGE (args, 2);
}
g_strlcpy (composevals.compose_type, g_object_get (config,
GIMP_VALUES_GET_STRING (args, 3), "image-2", &composevals.inputs[1].comp.object,
sizeof (composevals.compose_type)); "image-3", &composevals.inputs[2].comp.object,
"image-4", &composevals.inputs[3].comp.object,
NULL);
}
for (i = 0; i < MAX_COMPOSE_IMAGES; i++) for (i = 0; i < MAX_COMPOSE_IMAGES; i++)
{ {
@ -726,8 +754,6 @@ compose_run (GimpProcedure *procedure,
break; break;
case GIMP_RUN_WITH_LAST_VALS: case GIMP_RUN_WITH_LAST_VALS:
gimp_get_data (name, &composevals);
compose_by_drawable = TRUE; compose_by_drawable = TRUE;
break; break;
@ -736,17 +762,47 @@ compose_run (GimpProcedure *procedure,
} }
} }
compose_idx = gimp_procedure_config_get_choice_id (config, "compose-type");
if (compose_idx >= 0 && compose_idx < G_N_ELEMENTS (compose_dsc))
{
g_strlcpy (composevals.compose_type,
compose_dsc[compose_idx].compose_type,
sizeof (composevals.compose_type));
}
gimp_progress_init (_("Composing")); gimp_progress_init (_("Composing"));
image = compose (composevals.compose_type, image = compose (composevals.compose_type,
composevals.inputs, composevals.inputs,
compose_by_drawable); compose_by_drawable,
config);
if (! image) if (! image)
return gimp_procedure_new_return_values (procedure, return gimp_procedure_new_return_values (procedure,
GIMP_PDB_EXECUTION_ERROR, GIMP_PDB_EXECUTION_ERROR,
NULL); NULL);
/* Save drawables/images in GimpProcedureConfig */
if (run_mode == GIMP_RUN_NONINTERACTIVE)
{
if (compose_by_drawable)
{
g_object_set (config,
"drawable-2", composevals.inputs[1].comp.object,
"drawable-3", composevals.inputs[2].comp.object,
"drawable-4", composevals.inputs[3].comp.object,
NULL);
}
else
{
g_object_set (config,
"image-2", composevals.inputs[1].comp.object,
"image-3", composevals.inputs[2].comp.object,
"image-4", composevals.inputs[3].comp.object,
NULL);
}
}
if (composevals.do_recompose) if (composevals.do_recompose)
{ {
gimp_displays_flush (); gimp_displays_flush ();
@ -760,9 +816,6 @@ compose_run (GimpProcedure *procedure,
gimp_display_new (image); gimp_display_new (image);
} }
if (run_mode == GIMP_RUN_INTERACTIVE)
gimp_set_data (name, &composevals, sizeof (ComposeVals));
return_vals = gimp_procedure_new_return_values (procedure, return_vals = gimp_procedure_new_return_values (procedure,
GIMP_PDB_SUCCESS, GIMP_PDB_SUCCESS,
NULL); NULL);
@ -926,9 +979,10 @@ perform_composition (COMPOSE_DSC curr_compose_dsc,
/* Compose an image from several gray-images */ /* Compose an image from several gray-images */
static GimpImage * static GimpImage *
compose (const gchar *compose_type, compose (const gchar *compose_type,
ComposeInput *inputs, ComposeInput *inputs,
gboolean compose_by_drawable) gboolean compose_by_drawable,
GimpProcedureConfig *config)
{ {
gint width, height; gint width, height;
gint num_images, compose_idx; gint num_images, compose_idx;
@ -1139,33 +1193,26 @@ create_new_image (GFile *file,
static gboolean static gboolean
compose_dialog (const gchar *compose_type, compose_dialog (GimpProcedure *procedure,
GimpDrawable *drawable) GimpProcedureConfig *config,
const gchar *compose_type,
GimpDrawable *drawable)
{ {
GtkWidget *dialog; GtkWidget *dialog;
GtkWidget *main_vbox; GtkWidget *main_vbox;
GtkWidget *frame; GtkWidget *frame;
GtkWidget *vbox; GtkWidget *vbox;
GtkWidget *hbox; GtkWidget *hbox;
GtkWidget *label;
GtkWidget *combo;
GtkWidget *grid; GtkWidget *grid;
GtkSizeGroup *size_group; GtkSizeGroup *size_group;
GimpLayer **layer_list; GimpLayer **layer_list;
gint compose_idx;
gint nlayers; gint nlayers;
gint j; gint j;
gboolean run; gboolean run;
/* Check default compose type */ /* Check default compose type */
composeint.compose_idx = 0; compose_idx = gimp_procedure_config_get_choice_id (config, "compose-type");
for (j = 0; j < G_N_ELEMENTS (compose_dsc); j++)
{
if (g_ascii_strcasecmp (compose_type, compose_dsc[j].compose_type) == 0)
{
composeint.compose_idx = j;
break;
}
}
/* Save original image width/height */ /* Save original image width/height */
composeint.width = gimp_drawable_get_width (drawable); composeint.width = gimp_drawable_get_width (drawable);
@ -1176,19 +1223,14 @@ compose_dialog (const gchar *compose_type,
layer_list = gimp_image_get_layers (gimp_item_get_image (GIMP_ITEM (drawable)), layer_list = gimp_image_get_layers (gimp_item_get_image (GIMP_ITEM (drawable)),
&nlayers); &nlayers);
dialog = gimp_dialog_new (_("Compose"), PLUG_IN_ROLE, dialog = gimp_procedure_dialog_new (procedure,
NULL, 0, GIMP_PROCEDURE_CONFIG (config),
gimp_standard_help_func, COMPOSE_PROC, _("Compose"));
_("_Cancel"), GTK_RESPONSE_CANCEL,
_("_OK"), GTK_RESPONSE_OK,
NULL);
gimp_dialog_set_alternative_button_order (GTK_DIALOG (dialog), gimp_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
GTK_RESPONSE_OK, GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL, GTK_RESPONSE_CANCEL,
-1); -1);
g_signal_connect (dialog, "response", g_signal_connect (dialog, "response",
G_CALLBACK (check_response), G_CALLBACK (check_response),
@ -1196,53 +1238,20 @@ compose_dialog (const gchar *compose_type,
gimp_window_set_transient (GTK_WINDOW (dialog)); gimp_window_set_transient (GTK_WINDOW (dialog));
main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
main_vbox, TRUE, TRUE, 0);
gtk_widget_show (main_vbox);
/* Compose type combo */ /* Compose type combo */
gimp_procedure_dialog_get_label (GIMP_PROCEDURE_DIALOG (dialog),
"compose-label", _("Compose Channels"),
FALSE, FALSE);
frame = gimp_frame_new (_("Compose Channels")); gimp_procedure_dialog_fill_frame (GIMP_PROCEDURE_DIALOG (dialog),
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0); "compose-frame", "compose-label", FALSE,
gtk_widget_show (frame); "compose-type");
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); main_vbox = gimp_procedure_dialog_fill_box (GIMP_PROCEDURE_DIALOG (dialog),
gtk_container_add (GTK_CONTAINER (frame), hbox); "compose-vbox", "compose-frame",
gtk_widget_show (hbox); NULL);
gimp_procedure_dialog_fill (GIMP_PROCEDURE_DIALOG (dialog),
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); "compose-vbox", NULL);
label = gtk_label_new_with_mnemonic (_("Color _model:"));
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
gtk_size_group_add_widget (size_group, label);
g_object_unref (size_group);
combo = g_object_new (GIMP_TYPE_INT_COMBO_BOX, NULL);
for (j = 0; j < G_N_ELEMENTS (compose_dsc); j++)
{
gchar *label = g_strdup (gettext (compose_dsc[j].compose_type));
gchar *l;
for (l = label; *l; l++)
if (*l == '-' || *l == '_')
*l = ' ';
gimp_int_combo_box_append (GIMP_INT_COMBO_BOX (combo),
GIMP_INT_STORE_LABEL, label,
GIMP_INT_STORE_VALUE, j,
-1);
g_free (label);
}
gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
gtk_widget_show (combo);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
/* Channel representation grid */ /* Channel representation grid */
@ -1260,6 +1269,8 @@ compose_dialog (const gchar *compose_type,
gtk_box_pack_start (GTK_BOX (vbox), grid, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), grid, FALSE, FALSE, 0);
gtk_widget_show (grid); gtk_widget_show (grid);
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
for (j = 0; j < MAX_COMPOSE_IMAGES; j++) for (j = 0; j < MAX_COMPOSE_IMAGES; j++)
{ {
GtkWidget *image; GtkWidget *image;
@ -1271,7 +1282,6 @@ compose_dialog (const gchar *compose_type,
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_grid_attach (GTK_GRID (grid), hbox, 0, j, 1, 1); gtk_grid_attach (GTK_GRID (grid), hbox, 0, j, 1, 1);
// GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (hbox); gtk_widget_show (hbox);
gtk_size_group_add_widget (size_group, hbox); gtk_size_group_add_widget (size_group, hbox);
@ -1285,8 +1295,8 @@ compose_dialog (const gchar *compose_type,
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label); gtk_widget_show (label);
if (composeint.compose_idx >= 0 && if (compose_idx >= 0 &&
nlayers >= compose_dsc[composeint.compose_idx].num_images && nlayers >= compose_dsc[compose_idx].num_images &&
j < nlayers) j < nlayers)
{ {
composeint.selected[j].comp.object = layer_list[j]; composeint.selected[j].comp.object = layer_list[j];
@ -1309,7 +1319,6 @@ compose_dialog (const gchar *compose_type,
GIMP_INT_STORE_ICON_NAME, GIMP_ICON_CHANNEL_GRAY, GIMP_INT_STORE_ICON_NAME, GIMP_ICON_CHANNEL_GRAY,
-1); -1);
gtk_grid_attach (GTK_GRID (grid), combo, 1, j, 1, 1); gtk_grid_attach (GTK_GRID (grid), combo, 1, j, 1, 1);
// GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_widget_show (combo); gtk_widget_show (combo);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo); gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
@ -1337,14 +1346,14 @@ compose_dialog (const gchar *compose_type,
g_free (layer_list); g_free (layer_list);
/* Calls the combo callback and sets icons, labels and sensitivity */ /* Calls the combo callback and sets icons, labels and sensitivity */
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), g_signal_connect (config, "notify::compose-type",
composeint.compose_idx, G_CALLBACK (type_combo_callback),
G_CALLBACK (type_combo_callback), NULL);
NULL, NULL); type_combo_callback (config);
gtk_widget_show (dialog); gtk_widget_show (dialog);
run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK); run = gimp_procedure_dialog_run (GIMP_PROCEDURE_DIALOG (dialog));
gtk_widget_destroy (dialog); gtk_widget_destroy (dialog);
@ -1363,7 +1372,7 @@ compose_dialog (const gchar *compose_type,
} }
strcpy (composevals.compose_type, strcpy (composevals.compose_type,
compose_dsc[composeint.compose_idx].compose_type); compose_dsc[compose_idx].compose_type);
} }
return run; return run;
@ -1464,46 +1473,46 @@ scale_callback (GimpLabelSpin *scale,
} }
static void static void
type_combo_callback (GimpIntComboBox *combo, type_combo_callback (GimpProcedureConfig *config)
gpointer data)
{ {
if (gimp_int_combo_box_get_active (combo, &composeint.compose_idx)) gboolean combo4;
gboolean scale4;
gint compose_idx;
gint j;
if (config)
compose_idx = gimp_procedure_config_get_choice_id (config, "compose-type");
else
return;
for (j = 0; j < MAX_COMPOSE_IMAGES; j++)
{ {
gboolean combo4; GtkWidget *label = composeint.channel_label[j];
gboolean scale4; GtkWidget *image = composeint.channel_icon[j];
gint compose_idx; const gchar *text = compose_dsc[compose_idx].components[j].name;
gint j; const gchar *icon = compose_dsc[compose_idx].components[j].icon;
compose_idx = composeint.compose_idx; gtk_label_set_text_with_mnemonic (GTK_LABEL (label),
text ? gettext (text) : "");
for (j = 0; j < MAX_COMPOSE_IMAGES; j++) if (icon)
{ {
GtkWidget *label = composeint.channel_label[j]; gtk_image_set_from_icon_name (GTK_IMAGE (image),
GtkWidget *image = composeint.channel_icon[j]; icon, GTK_ICON_SIZE_BUTTON);
const gchar *text = compose_dsc[compose_idx].components[j].name; gtk_widget_show (image);
const gchar *icon = compose_dsc[compose_idx].components[j].icon; }
else
gtk_label_set_text_with_mnemonic (GTK_LABEL (label), {
text ? gettext (text) : ""); gtk_image_clear (GTK_IMAGE (image));
gtk_widget_hide (image);
if (icon)
{
gtk_image_set_from_icon_name (GTK_IMAGE (image),
icon, GTK_ICON_SIZE_BUTTON);
gtk_widget_show (image);
}
else
{
gtk_image_clear (GTK_IMAGE (image));
gtk_widget_hide (image);
}
} }
/* Set sensitivity of last menu */
combo4 = (compose_dsc[compose_idx].num_images == 4);
gtk_widget_set_sensitive (composeint.channel_menu[3], combo4);
scale4 = combo4 && !composeint.selected[3].is_object;
gtk_widget_set_sensitive (composeint.scales[3], scale4);
} }
/* Set sensitivity of last menu */
combo4 = (compose_dsc[compose_idx].num_images == 4);
gtk_widget_set_sensitive (composeint.channel_menu[3], combo4);
scale4 = combo4 && !composeint.selected[3].is_object;
gtk_widget_set_sensitive (composeint.scales[3], scale4);
} }