[gimp] app: change the "XCF compat" stuff to "XCF compression"
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: change the "XCF compat" stuff to "XCF compression"
- Date: Thu, 23 Mar 2017 17:05:33 +0000 (UTC)
commit a0521a520f2ccd6cdd5bfd9a99dadd9c9422c6fe
Author: Michael Natterer <mitch gimp org>
Date: Thu Mar 23 18:03:27 2017 +0100
app: change the "XCF compat" stuff to "XCF compression"
Both in the GimpImage API and in the GUI. The toggle in the save
dialog now controls ZLIB compression directly. Changed the various
info labels accordingly. Ditch the XCF parasite that saved the XCF
compat mode.
app/actions/file-commands.c | 27 +-----------
app/core/gimpimage-private.h | 2 +-
app/core/gimpimage.c | 10 ++--
app/core/gimpimage.h | 6 +-
app/dialogs/file-save-dialog.c | 14 +++---
app/dialogs/file-save-dialog.h | 2 +-
app/widgets/gimpsavedialog.c | 96 +++++++++++++++++-----------------------
app/widgets/gimpsavedialog.h | 4 +-
app/xcf/xcf-load.c | 5 ++-
app/xcf/xcf-save.c | 33 ++------------
app/xcf/xcf.c | 6 +-
11 files changed, 71 insertions(+), 134 deletions(-)
---
diff --git a/app/actions/file-commands.c b/app/actions/file-commands.c
index 8b297d2..8a22639 100644
--- a/app/actions/file-commands.c
+++ b/app/actions/file-commands.c
@@ -258,37 +258,12 @@ file_save_cmd_callback (GtkAction *action,
if (file && save_proc)
{
- const gchar *version_string;
- gint rle_version;
- gint zlib_version;
- gboolean compat_possible = FALSE;
-
- gimp_image_get_xcf_version (image, FALSE,
- &rle_version, &version_string);
- gimp_image_get_xcf_version (image, TRUE,
- &zlib_version, NULL);
-
- if (rle_version != zlib_version)
- compat_possible = TRUE;
-
- if (gimp_image_get_xcf_compat_mode (image) &&
- ! compat_possible)
- {
- gimp_message (image->gimp, G_OBJECT (display),
- GIMP_MESSAGE_WARNING,
- _("The image uses features from %s and "
- "cannot be saved for older GIMP "
- "versions."),
- version_string);
- }
-
saved = file_save_dialog_save_image (GIMP_PROGRESS (display),
gimp, image, file,
save_proc,
GIMP_RUN_WITH_LAST_VALS,
TRUE, FALSE, FALSE,
- gimp_image_get_xcf_compat_mode (image) &&
- compat_possible,
+ gimp_image_get_xcf_compression (image),
TRUE);
break;
}
diff --git a/app/core/gimpimage-private.h b/app/core/gimpimage-private.h
index 0a2e2e2..262159b 100644
--- a/app/core/gimpimage-private.h
+++ b/app/core/gimpimage-private.h
@@ -74,7 +74,7 @@ struct _GimpImagePrivate
GFile *save_a_copy_file; /* the image's save-a-copy file */
GFile *untitled_file; /* a file saying "Untitled" */
- gboolean xcf_compat_mode; /* if possible, save compat XCF */
+ gboolean xcf_compression; /* XCF compression enabled? */
gint dirty; /* dirty flag -- # of ops */
gint64 dirty_time; /* time when image became dirty */
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index f032a1a..8531253 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -2539,20 +2539,20 @@ gimp_image_get_xcf_version (GimpImage *image,
}
void
-gimp_image_set_xcf_compat_mode (GimpImage *image,
- gboolean compat_mode)
+gimp_image_set_xcf_compression (GimpImage *image,
+ gboolean compression)
{
g_return_if_fail (GIMP_IS_IMAGE (image));
- GIMP_IMAGE_GET_PRIVATE (image)->xcf_compat_mode = compat_mode;
+ GIMP_IMAGE_GET_PRIVATE (image)->xcf_compression = compression;
}
gboolean
-gimp_image_get_xcf_compat_mode (GimpImage *image)
+gimp_image_get_xcf_compression (GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
- return GIMP_IMAGE_GET_PRIVATE (image)->xcf_compat_mode;
+ return GIMP_IMAGE_GET_PRIVATE (image)->xcf_compression;
}
void
diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h
index aa543cf..81489a8 100644
--- a/app/core/gimpimage.h
+++ b/app/core/gimpimage.h
@@ -171,9 +171,9 @@ gint gimp_image_get_xcf_version (GimpImage *image,
gint *gimp_version,
const gchar **version_string);
-void gimp_image_set_xcf_compat_mode (GimpImage *image,
- gboolean compat_mode);
-gboolean gimp_image_get_xcf_compat_mode (GimpImage *image);
+void gimp_image_set_xcf_compression (GimpImage *image,
+ gboolean compression);
+gboolean gimp_image_get_xcf_compression (GimpImage *image);
void gimp_image_set_resolution (GimpImage *image,
gdouble xres,
diff --git a/app/dialogs/file-save-dialog.c b/app/dialogs/file-save-dialog.c
index d3e0a60..b22f88b 100644
--- a/app/dialogs/file-save-dialog.c
+++ b/app/dialogs/file-save-dialog.c
@@ -179,17 +179,15 @@ file_save_dialog_response (GtkWidget *dialog,
case CHECK_URI_OK:
{
- gboolean xcf_compat = FALSE;
+ gboolean xcf_compression = FALSE;
gimp_file_dialog_set_sensitive (file_dialog, FALSE);
if (GIMP_IS_SAVE_DIALOG (dialog))
{
- GimpSaveDialog* save_dialog = GIMP_SAVE_DIALOG (dialog);
-
- xcf_compat = save_dialog->compat &&
- gtk_widget_get_sensitive (save_dialog->compat_toggle);
+ xcf_compression = GIMP_SAVE_DIALOG (dialog)->compression;
}
+
if (file_save_dialog_save_image (GIMP_PROGRESS (dialog),
gimp,
file_dialog->image,
@@ -200,7 +198,7 @@ file_save_dialog_response (GtkWidget *dialog,
! GIMP_SAVE_DIALOG (dialog)->save_a_copy,
FALSE,
GIMP_IS_EXPORT_DIALOG (dialog),
- xcf_compat,
+ xcf_compression,
FALSE))
{
/* Save was successful, now store the URI in a couple of
@@ -753,7 +751,7 @@ file_save_dialog_save_image (GimpProgress *progress,
gboolean change_saved_state,
gboolean export_backward,
gboolean export_forward,
- gboolean xcf_compat,
+ gboolean xcf_compression,
gboolean verbose_cancel)
{
GimpPDBStatusType status;
@@ -768,7 +766,7 @@ file_save_dialog_save_image (GimpProgress *progress,
gimp_action_group_set_action_sensitive (list->data, "file-quit", FALSE);
}
- gimp_image_set_xcf_compat_mode (image, xcf_compat);
+ gimp_image_set_xcf_compression (image, xcf_compression);
status = file_save (gimp, image, progress, file,
save_proc, run_mode,
diff --git a/app/dialogs/file-save-dialog.h b/app/dialogs/file-save-dialog.h
index d3539c9..9465c59 100644
--- a/app/dialogs/file-save-dialog.h
+++ b/app/dialogs/file-save-dialog.h
@@ -34,7 +34,7 @@ gboolean file_save_dialog_save_image (GimpProgress *progress_and_handl
gboolean save_a_copy,
gboolean export_backward,
gboolean export_forward,
- gboolean xcf_compat,
+ gboolean xcf_compression,
gboolean verbose_cancel);
diff --git a/app/widgets/gimpsavedialog.c b/app/widgets/gimpsavedialog.c
index 565fe84..febd31d 100644
--- a/app/widgets/gimpsavedialog.c
+++ b/app/widgets/gimpsavedialog.c
@@ -46,7 +46,7 @@ typedef struct _GimpSaveDialogState GimpSaveDialogState;
struct _GimpSaveDialogState
{
gchar *filter_name;
- gboolean compat;
+ gboolean compression;
};
@@ -57,8 +57,10 @@ static void gimp_save_dialog_save_state (GimpFileDialog *dialog,
static void gimp_save_dialog_load_state (GimpFileDialog *dialog,
const gchar *state_name);
-static void gimp_save_dialog_add_compat_toggle (GimpSaveDialog *dialog);
-static void gimp_save_dialog_compat_toggled (GtkToggleButton *button,
+static void gimp_save_dialog_add_compression_toggle
+ (GimpSaveDialog *dialog);
+static void gimp_save_dialog_compression_toggled
+ (GtkToggleButton *button,
GimpSaveDialog *dialog);
static GimpSaveDialogState
@@ -101,7 +103,7 @@ gimp_save_dialog_constructed (GObject *object)
*/
G_OBJECT_CLASS (parent_class)->constructed (object);
- gimp_save_dialog_add_compat_toggle (dialog);
+ gimp_save_dialog_add_compression_toggle (dialog);
}
static void
@@ -254,49 +256,37 @@ gimp_save_dialog_set_image (GimpSaveDialog *dialog,
if (rle_version == zlib_version)
{
- gtk_widget_set_sensitive (dialog->compat_toggle, FALSE);
- gtk_widget_set_sensitive (dialog->compat_info, FALSE);
-
- tooltip = g_strdup_printf (_("The image uses features from %s and "
- "cannot be saved for older GIMP "
- "versions."),
+ tooltip = g_strdup_printf (_("The image uses features from %s, disabling "
+ "compression won't make the XCF file "
+ "readable by older GIMP versions."),
version_string);
}
else
{
- gtk_widget_set_sensitive (dialog->compat_toggle, TRUE);
- gtk_widget_set_sensitive (dialog->compat_info, TRUE);
-
- tooltip = g_strdup_printf (_("Disables compression to make the XCF "
+ tooltip = g_strdup_printf (_("Keep compression disabled to make the XCF "
"file readable by %s and later."),
version_string);
- if (gimp_image_get_metadata (image))
- {
- gchar *temp_tooltip;
+ }
- temp_tooltip = g_strconcat (tooltip, "\n",
- _("Metadata won't be visible in GIMP "
- "older than version 2.10."), NULL);
- g_free (tooltip);
- tooltip = temp_tooltip;
- }
+ if (gimp_image_get_metadata (image))
+ {
+ gchar *temp_tooltip;
+
+ temp_tooltip = g_strconcat (tooltip, "\n",
+ _("Metadata won't be visible in GIMP "
+ "older than version 2.10."), NULL);
+ g_free (tooltip);
+ tooltip = temp_tooltip;
}
gtk_label_set_text (GTK_LABEL (dialog->compat_info), tooltip);
g_free (tooltip);
- gtk_widget_show (dialog->compat_toggle);
+ gtk_widget_show (dialog->compression_toggle);
gtk_widget_show (dialog->compat_info);
- /* We set the compatibility mode by default either if the image was
- * previously saved with the compatibility mode, or if it has never
- * been saved and the last GimpSaveDialogState had compatibility
- * mode ON.
- */
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->compat_toggle),
- gtk_widget_get_sensitive (dialog->compat_toggle) &&
- (gimp_image_get_xcf_compat_mode (image) ||
- (! gimp_image_get_file (image) && dialog->compat)));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->compression_toggle),
+ gimp_image_get_xcf_compression (image));
if (ext_file)
{
@@ -331,41 +321,37 @@ gimp_save_dialog_set_image (GimpSaveDialog *dialog,
/* private functions */
static void
-gimp_save_dialog_add_compat_toggle (GimpSaveDialog *dialog)
+gimp_save_dialog_add_compression_toggle (GimpSaveDialog *dialog)
{
- GtkWidget *compat_frame;
+ GtkWidget *frame;
- compat_frame = gimp_frame_new (NULL);
+ dialog->compression_toggle =
+ gtk_check_button_new_with_label (_("Save this XCF file with better but slower compression"));
- /* The checkbox. */
- dialog->compat_toggle =
- gtk_check_button_new_with_label (_("Save this XCF file with maximum compatibility"));
- gtk_frame_set_label_widget (GTK_FRAME (compat_frame),
- dialog->compat_toggle);
+ frame = gimp_frame_new (NULL);
+ gtk_frame_set_label_widget (GTK_FRAME (frame), dialog->compression_toggle);
+ gimp_file_dialog_add_extra_widget (GIMP_FILE_DIALOG (dialog), frame,
+ FALSE, FALSE, 0);
+ gtk_widget_show (frame);
- /* Additional information explaining what this mode does. */
+ /* Additional information explaining file compatibility things */
dialog->compat_info = gtk_label_new ("");
gtk_label_set_xalign (GTK_LABEL (dialog->compat_info), 0.0);
gimp_label_set_attributes (GTK_LABEL (dialog->compat_info),
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
-1);
- gtk_container_add (GTK_CONTAINER (compat_frame), dialog->compat_info);
-
- gimp_file_dialog_add_extra_widget (GIMP_FILE_DIALOG (dialog),
- compat_frame,
- FALSE, FALSE, 0);
- gtk_widget_show (compat_frame);
+ gtk_container_add (GTK_CONTAINER (frame), dialog->compat_info);
- g_signal_connect (dialog->compat_toggle, "toggled",
- G_CALLBACK (gimp_save_dialog_compat_toggled),
+ g_signal_connect (dialog->compression_toggle, "toggled",
+ G_CALLBACK (gimp_save_dialog_compression_toggled),
dialog);
}
static void
-gimp_save_dialog_compat_toggled (GtkToggleButton *button,
- GimpSaveDialog *dialog)
+gimp_save_dialog_compression_toggled (GtkToggleButton *button,
+ GimpSaveDialog *dialog)
{
- dialog->compat = gtk_toggle_button_get_active (button);
+ dialog->compression = gtk_toggle_button_get_active (button);
}
static GimpSaveDialogState *
@@ -381,7 +367,7 @@ gimp_save_dialog_get_state (GimpSaveDialog *dialog)
if (filter)
state->filter_name = g_strdup (gtk_file_filter_get_name (filter));
- state->compat = dialog->compat;
+ state->compression = dialog->compression;
return state;
}
@@ -412,7 +398,7 @@ gimp_save_dialog_set_state (GimpSaveDialog *dialog,
g_slist_free (filters);
}
- dialog->compat = state->compat;
+ dialog->compression = state->compression;
}
static void
diff --git a/app/widgets/gimpsavedialog.h b/app/widgets/gimpsavedialog.h
index fce26e5..f75f9e2 100644
--- a/app/widgets/gimpsavedialog.h
+++ b/app/widgets/gimpsavedialog.h
@@ -43,9 +43,9 @@ struct _GimpSaveDialog
gboolean close_after_saving;
GimpObject *display_to_close;
- GtkWidget *compat_toggle;
+ GtkWidget *compression_toggle;
GtkWidget *compat_info;
- gboolean compat;
+ gboolean compression;
};
struct _GimpSaveDialogClass
diff --git a/app/xcf/xcf-load.c b/app/xcf/xcf-load.c
index d58473c..ab6d287 100644
--- a/app/xcf/xcf-load.c
+++ b/app/xcf/xcf-load.c
@@ -380,7 +380,7 @@ xcf_load_image (Gimp *gimp,
{
GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
- gimp_image_set_xcf_compat_mode (image, TRUE);
+ /* just ditch it, it's unused but shouldn't be re-saved */
gimp_parasite_list_remove (private->parasites,
gimp_parasite_name (parasite));
}
@@ -696,6 +696,9 @@ xcf_load_image_props (XcfInfo *info,
info->compression = compression;
+ gimp_image_set_xcf_compression (image,
+ compression >= COMPRESS_ZLIB);
+
GIMP_LOG (XCF, "prop compression=%d", compression);
}
break;
diff --git a/app/xcf/xcf-save.c b/app/xcf/xcf-save.c
index db5fe88..4b19393 100644
--- a/app/xcf/xcf-save.c
+++ b/app/xcf/xcf-save.c
@@ -344,11 +344,10 @@ xcf_save_image_props (XcfInfo *info,
GimpImage *image,
GError **error)
{
- GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
- GimpParasite *grid_parasite = NULL;
- GimpParasite *meta_parasite = NULL;
- GimpParasite *compat_parasite = NULL;
- GimpUnit unit = gimp_image_get_unit (image);
+ GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
+ GimpParasite *grid_parasite = NULL;
+ GimpParasite *meta_parasite = NULL;
+ GimpUnit unit = gimp_image_get_unit (image);
gdouble xres;
gdouble yres;
@@ -418,23 +417,6 @@ xcf_save_image_props (XcfInfo *info,
}
}
- if (gimp_image_get_xcf_compat_mode (image))
- {
- gint gimp_version;
-
- /* Save the GIMP version we are trying to get compatible with.
- * This specific information is unused as of now though.
- */
- gimp_image_get_xcf_version (image, FALSE, &gimp_version, NULL);
- gimp_version = g_htonl (gimp_version);
-
- compat_parasite = gimp_parasite_new ("gimp-xcf-compatibility-mode",
- GIMP_PARASITE_PERSISTENT,
- sizeof (gimp_version),
- &gimp_version);
- gimp_parasite_list_add (private->parasites, compat_parasite);
- }
-
if (gimp_parasite_list_length (private->parasites) > 0)
{
xcf_check_error (xcf_save_prop (info, image, PROP_PARASITES, error,
@@ -455,13 +437,6 @@ xcf_save_image_props (XcfInfo *info,
gimp_parasite_free (meta_parasite);
}
- if (compat_parasite)
- {
- gimp_parasite_list_remove (private->parasites,
- gimp_parasite_name (compat_parasite));
- gimp_parasite_free (compat_parasite);
- }
-
xcf_check_error (xcf_save_prop (info, image, PROP_END, error));
return TRUE;
diff --git a/app/xcf/xcf.c b/app/xcf/xcf.c
index 6bfd0a8..d74d4fe 100644
--- a/app/xcf/xcf.c
+++ b/app/xcf/xcf.c
@@ -363,10 +363,10 @@ xcf_save_stream (Gimp *gimp,
info.progress = progress;
info.file = output_file;
- if (gimp_image_get_xcf_compat_mode (image))
- info.compression = COMPRESS_RLE;
- else
+ if (gimp_image_get_xcf_compression (image))
info.compression = COMPRESS_ZLIB;
+ else
+ info.compression = COMPRESS_RLE;
info.file_version = gimp_image_get_xcf_version (image,
info.compression ==
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]