mirror of https://github.com/GNOME/gimp.git
libgimp: clean out the "interactive" intermediate dialog which was hidden…
… since forever anyway! GIMP used to have a second export dialog, a generically generated one, appearing either before or after (depending on when gimp_export_image() was called) the custom export dialog implemented by the plug-in code. This has been hidden deep in code since forever (since version 2.8.0 in fact, I believe) and only kept hidden behind an environment variable "GIMP_INTERACTIVE_EXPORT". I don't think we'll ever revive this, so let's clean up. In fact, not one, but in worst case even 2 more dialogs were hidden behind this variable! The first dialog (confirm_save_dialog()) was a confirmation when the selected drawable was a layer mask or a channel (and not a layer). Most export code don't even seem to care about the selected drawables anymore anyway (cf. issue #7370), except with gimp_file_save() non-interactively (issue #8855), which is a real mess of inconsistency anyway. The second dialog (export_dialog()) was listing the various actions to do on a copy of the image to help the plug-in (e.g. merge layers/flatten image, etc.) and possibly give choices to some of these actions. Though there is definitely no reason to request this kind of thing anymore, especially for a short-lasting image copy, the list of action could still be interesting in the future, not as information of what is going to be done, but as information of the kind of data loss of the exported format. I could imagine we want to be able to reuse such information for generating types of data loss per format in the export dialog, in particular in the context of my long-term export workflow refactoring (from which resizing before export such as #2531 are part of, but the whole refactoring project is much wider). In the whole discussion of #5858, there will be the question on whether we don't want plug-ins to be directly given a "ready-to-use" image depending on capabilities they advertized in create_procedure().
This commit is contained in:
parent
b4f84dfd8f
commit
0dc9ff7c06
|
@ -551,258 +551,6 @@ export_action_perform (const ExportAction *action,
|
|||
|
||||
/* dialog functions */
|
||||
|
||||
static void
|
||||
export_toggle_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
gint *choice = (gint *) data;
|
||||
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
|
||||
*choice = FALSE;
|
||||
else
|
||||
*choice = TRUE;
|
||||
}
|
||||
|
||||
static GimpExportReturn
|
||||
confirm_save_dialog (const gchar *message,
|
||||
const gchar *format_name)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *image;
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *label;
|
||||
gchar *text;
|
||||
GimpExportReturn retval;
|
||||
|
||||
g_return_val_if_fail (message != NULL, GIMP_EXPORT_CANCEL);
|
||||
g_return_val_if_fail (format_name != NULL, GIMP_EXPORT_CANCEL);
|
||||
|
||||
dialog = gimp_dialog_new (_("Confirm Save"), "gimp-export-image-confirm",
|
||||
NULL, 0,
|
||||
gimp_standard_help_func,
|
||||
"gimp-export-confirm-dialog",
|
||||
|
||||
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
||||
_("C_onfirm"), GTK_RESPONSE_OK,
|
||||
|
||||
NULL);
|
||||
|
||||
gimp_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
|
||||
GTK_RESPONSE_OK,
|
||||
GTK_RESPONSE_CANCEL,
|
||||
-1);
|
||||
|
||||
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
|
||||
gimp_window_set_transient (GTK_WINDOW (dialog));
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
|
||||
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
|
||||
hbox, TRUE, TRUE, 0);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (hbox), 12);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
image = gtk_image_new_from_icon_name ("dialog-warning",
|
||||
GTK_ICON_SIZE_DIALOG);
|
||||
gtk_widget_set_valign (image, GTK_ALIGN_START);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
|
||||
gtk_widget_show (image);
|
||||
|
||||
main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), main_vbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (main_vbox);
|
||||
|
||||
text = g_strdup_printf (message, format_name);
|
||||
label = gtk_label_new (text);
|
||||
g_free (text);
|
||||
|
||||
gimp_label_set_attributes (GTK_LABEL (label),
|
||||
PANGO_ATTR_SCALE, PANGO_SCALE_LARGE,
|
||||
PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD,
|
||||
-1);
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
||||
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
|
||||
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
switch (gimp_dialog_run (GIMP_DIALOG (dialog)))
|
||||
{
|
||||
case GTK_RESPONSE_OK:
|
||||
retval = GIMP_EXPORT_EXPORT;
|
||||
break;
|
||||
|
||||
default:
|
||||
retval = GIMP_EXPORT_CANCEL;
|
||||
break;
|
||||
}
|
||||
|
||||
gtk_widget_destroy (dialog);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static GimpExportReturn
|
||||
export_dialog (GSList *actions,
|
||||
const gchar *format_name)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *image;
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *label;
|
||||
GSList *list;
|
||||
gchar *text;
|
||||
GimpExportReturn retval;
|
||||
|
||||
g_return_val_if_fail (actions != NULL, GIMP_EXPORT_CANCEL);
|
||||
g_return_val_if_fail (format_name != NULL, GIMP_EXPORT_CANCEL);
|
||||
|
||||
dialog = gimp_dialog_new (_("Export File"), "gimp-export-image",
|
||||
NULL, 0,
|
||||
gimp_standard_help_func, "gimp-export-dialog",
|
||||
|
||||
_("_Ignore"), GTK_RESPONSE_NO,
|
||||
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
||||
_("_Export"), GTK_RESPONSE_OK,
|
||||
|
||||
NULL);
|
||||
|
||||
gimp_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
|
||||
GTK_RESPONSE_NO,
|
||||
GTK_RESPONSE_OK,
|
||||
GTK_RESPONSE_CANCEL,
|
||||
-1);
|
||||
|
||||
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
|
||||
gimp_window_set_transient (GTK_WINDOW (dialog));
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
|
||||
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
|
||||
hbox, TRUE, TRUE, 0);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (hbox), 12);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
image = gtk_image_new_from_icon_name ("dialog-information",
|
||||
GTK_ICON_SIZE_DIALOG);
|
||||
gtk_widget_set_valign (image, GTK_ALIGN_START);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
|
||||
gtk_widget_show (image);
|
||||
|
||||
main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), main_vbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (main_vbox);
|
||||
|
||||
/* the headline */
|
||||
text = g_strdup_printf (_("Your image should be exported before it "
|
||||
"can be saved as %s for the following reasons:"),
|
||||
format_name);
|
||||
label = gtk_label_new (text);
|
||||
g_free (text);
|
||||
|
||||
gimp_label_set_attributes (GTK_LABEL (label),
|
||||
PANGO_ATTR_SCALE, PANGO_SCALE_LARGE,
|
||||
-1);
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
||||
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
|
||||
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
for (list = actions; list; list = g_slist_next (list))
|
||||
{
|
||||
ExportAction *action = list->data;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *vbox;
|
||||
|
||||
text = g_strdup_printf (gettext (action->reason), format_name);
|
||||
frame = gimp_frame_new (text);
|
||||
g_free (text);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
||||
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
||||
|
||||
if (action->possibilities[0] && action->possibilities[1])
|
||||
{
|
||||
GtkWidget *button;
|
||||
GSList *radio_group = NULL;
|
||||
|
||||
button = gtk_radio_button_new_with_label (radio_group,
|
||||
gettext (action->possibilities[0]));
|
||||
gtk_label_set_justify (GTK_LABEL (gtk_bin_get_child (GTK_BIN (button))),
|
||||
GTK_JUSTIFY_LEFT);
|
||||
radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
|
||||
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
||||
g_signal_connect (button, "toggled",
|
||||
G_CALLBACK (export_toggle_callback),
|
||||
&action->choice);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
|
||||
(action->choice == 0));
|
||||
gtk_widget_show (button);
|
||||
|
||||
button = gtk_radio_button_new_with_label (radio_group,
|
||||
gettext (action->possibilities[1]));
|
||||
gtk_label_set_justify (GTK_LABEL (gtk_bin_get_child (GTK_BIN (button))),
|
||||
GTK_JUSTIFY_LEFT);
|
||||
radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
|
||||
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
|
||||
(action->choice == 1));
|
||||
gtk_widget_show (button);
|
||||
}
|
||||
else if (action->possibilities[0])
|
||||
{
|
||||
label = gtk_label_new (gettext (action->possibilities[0]));
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
||||
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
|
||||
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
action->choice = 0;
|
||||
}
|
||||
|
||||
gtk_widget_show (vbox);
|
||||
}
|
||||
|
||||
/* the footline */
|
||||
label = gtk_label_new (_("The export conversion won't modify your "
|
||||
"original image."));
|
||||
gimp_label_set_attributes (GTK_LABEL (label),
|
||||
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
|
||||
-1);
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
||||
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
|
||||
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
switch (gimp_dialog_run (GIMP_DIALOG (dialog)))
|
||||
{
|
||||
case GTK_RESPONSE_OK:
|
||||
retval = GIMP_EXPORT_EXPORT;
|
||||
break;
|
||||
|
||||
case GTK_RESPONSE_NO:
|
||||
retval = GIMP_EXPORT_IGNORE;
|
||||
break;
|
||||
|
||||
default:
|
||||
retval = GIMP_EXPORT_CANCEL;
|
||||
break;
|
||||
}
|
||||
|
||||
gtk_widget_destroy (dialog);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_export_image:
|
||||
* @image: Pointer to the image.
|
||||
|
@ -848,7 +596,6 @@ gimp_export_image (GimpImage **image,
|
|||
GList *layers;
|
||||
GList *iter;
|
||||
GType drawables_type = G_TYPE_NONE;
|
||||
gboolean interactive = FALSE;
|
||||
gboolean added_flatten = FALSE;
|
||||
gboolean has_layer_masks = FALSE;
|
||||
gboolean background_has_alpha = TRUE;
|
||||
|
@ -879,37 +626,6 @@ gimp_export_image (GimpImage **image,
|
|||
if (capabilities & GIMP_EXPORT_CAN_HANDLE_LAYER_MASKS)
|
||||
capabilities |= GIMP_EXPORT_CAN_HANDLE_LAYERS;
|
||||
|
||||
if (format_name && g_getenv ("GIMP_INTERACTIVE_EXPORT"))
|
||||
interactive = TRUE;
|
||||
|
||||
/* ask for confirmation if the user is not saving a layer (see bug #51114) */
|
||||
if (interactive &&
|
||||
! g_type_is_a (drawables_type, GIMP_TYPE_LAYER) &&
|
||||
! (capabilities & GIMP_EXPORT_CAN_HANDLE_LAYERS))
|
||||
{
|
||||
if (g_type_is_a (drawables_type, GIMP_TYPE_LAYER_MASK))
|
||||
{
|
||||
retval = confirm_save_dialog
|
||||
(_("You are about to save a layer mask as %s.\n"
|
||||
"This will not save the visible layers."), format_name);
|
||||
}
|
||||
else if (g_type_is_a (drawables_type, GIMP_TYPE_CHANNEL))
|
||||
{
|
||||
retval = confirm_save_dialog
|
||||
(_("You are about to save a channel (saved selection) as %s.\n"
|
||||
"This will not save the visible layers."), format_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* this should not happen */
|
||||
g_warning ("%s: unknown drawable type!", G_STRFUNC);
|
||||
}
|
||||
|
||||
/* cancel - the user can then select an appropriate layer to save */
|
||||
if (retval == GIMP_EXPORT_CANCEL)
|
||||
return GIMP_EXPORT_CANCEL;
|
||||
}
|
||||
|
||||
/* Merge down layer effects for non-project file formats */
|
||||
if (! (capabilities & GIMP_EXPORT_CAN_HANDLE_LAYER_EFFECTS))
|
||||
actions = g_slist_prepend (actions, &export_action_merge_layer_effects);
|
||||
|
@ -1158,10 +874,7 @@ gimp_export_image (GimpImage **image,
|
|||
{
|
||||
actions = g_slist_reverse (actions);
|
||||
|
||||
if (interactive)
|
||||
retval = export_dialog (actions, format_name);
|
||||
else
|
||||
retval = GIMP_EXPORT_EXPORT;
|
||||
retval = GIMP_EXPORT_EXPORT;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue