[gimp/gimp-2-10] Issue #2055: make save dialog compatibility information understandable.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] Issue #2055: make save dialog compatibility information understandable.
- Date: Wed, 12 Sep 2018 11:54:34 +0000 (UTC)
commit 536af959f10168555cde86345beb8198857a09e2
Author: Jehan <jehan girinstud io>
Date: Mon Sep 10 16:57:21 2018 +0200
Issue #2055: make save dialog compatibility information understandable.
* The minimum GIMP version for this XCF is always written down when it
is GIMP 2.8 or over.
* The list of features warrating the minimum version is now listed in an
expander container rather than as tooltip (making the list actually
discoverable!).
* The warning on compression is now displayed as its own text under the
checkbox (only when checking the box actually changes anything
compatibility-wise), and not as additional text to the minimum GIMP
version label. Otherwise it had far too much weight on the minimum
compatible GIMP version text and people were wondering what it meant.
We should not tell people what the checkbox cannot do (it cannot
improve compatibility in some cases), only what it can do (it can
improve compatibility in other cases).
* Update the feature list real-time when checking the compression box
(making it even more obvious that tile compression may have a say in
compatibility).
* Metadata info is still added on the GIMP version label as it does not
limit compatibility of the XCF file itself.
(cherry picked from commit 573d8175395aa139b6d4a3fdf5c83ced1b2f876f)
app/widgets/gimpsavedialog.c | 176 +++++++++++++++++++++++++++----------------
app/widgets/gimpsavedialog.h | 2 +-
2 files changed, 114 insertions(+), 64 deletions(-)
---
diff --git a/app/widgets/gimpsavedialog.c b/app/widgets/gimpsavedialog.c
index 167fbc8628..e215e377e1 100644
--- a/app/widgets/gimpsavedialog.c
+++ b/app/widgets/gimpsavedialog.c
@@ -57,8 +57,7 @@ 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_compression_toggle
- (GimpSaveDialog *dialog);
+static void gimp_save_dialog_add_extra_widgets (GimpSaveDialog *dialog);
static void gimp_save_dialog_compression_toggled
(GtkToggleButton *button,
GimpSaveDialog *dialog);
@@ -103,7 +102,7 @@ gimp_save_dialog_constructed (GObject *object)
*/
G_OBJECT_CLASS (parent_class)->constructed (object);
- gimp_save_dialog_add_compression_toggle (dialog);
+ gimp_save_dialog_add_extra_widgets (dialog);
}
static void
@@ -160,6 +159,7 @@ gimp_save_dialog_set_image (GimpSaveDialog *dialog,
GimpObject *display)
{
GimpFileDialog *file_dialog;
+ GtkWidget *compression_toggle;
GFile *dir_file = NULL;
GFile *name_file = NULL;
GFile *ext_file = NULL;
@@ -167,10 +167,6 @@ gimp_save_dialog_set_image (GimpSaveDialog *dialog,
const gchar *version_string;
gint rle_version;
gint zlib_version;
- gchar *rle_reason = NULL;
- gchar *zlib_reason = NULL;
- gchar *compat_hint;
- gchar *compat_tooltip;
g_return_if_fail (GIMP_IS_SAVE_DIALOG (dialog));
g_return_if_fail (GIMP_IS_IMAGE (image));
@@ -255,52 +251,35 @@ gimp_save_dialog_set_image (GimpSaveDialog *dialog,
ext_file = g_file_new_for_uri ("file:///we/only/care/about/extension.xcf");
gimp_image_get_xcf_version (image, FALSE, &rle_version,
- &version_string, &rle_reason);
+ &version_string, NULL);
gimp_image_get_xcf_version (image, TRUE, &zlib_version,
- NULL, &zlib_reason);
-
- if (rle_version == zlib_version)
- {
- compat_hint =
- g_strdup_printf (_("The image uses features from %s, disabling "
- "compression won't make the XCF file "
- "readable by older GIMP versions."),
- version_string);
- compat_tooltip = rle_reason;
- g_free (zlib_reason);
- }
- else
+ NULL, NULL);
+ if (rle_version != zlib_version)
{
- compat_hint =
- g_strdup_printf (_("Keep compression disabled to make the XCF "
- "file readable by %s and later."),
- version_string);
- compat_tooltip = zlib_reason;
- g_free (rle_reason);
- }
-
- if (gimp_image_get_metadata (image))
- {
- gchar *temp_hint;
-
- temp_hint = g_strconcat (compat_hint, "\n",
- _("Metadata won't be visible in GIMP "
- "older than version 2.10."), NULL);
- g_free (compat_hint);
- compat_hint = temp_hint;
+ GtkWidget *label;
+ gchar *text;
+
+ text = g_strdup_printf (_("Keep compression disabled to make the XCF "
+ "file readable by %s and later."),
+ version_string);
+ label = gtk_label_new (text);
+ gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+ gimp_label_set_attributes (GTK_LABEL (label),
+ PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
+ -1);
+ gtk_container_add (GTK_CONTAINER (dialog->compression_frame),
+ label);
+ gtk_widget_show (label);
+ g_free (text);
}
- gtk_label_set_text (GTK_LABEL (dialog->compat_info), compat_hint);
- g_free (compat_hint);
-
- gimp_help_set_help_data (dialog->compat_info, compat_tooltip, NULL);
- g_free (compat_tooltip);
-
- gtk_widget_show (dialog->compression_toggle);
- gtk_widget_show (dialog->compat_info);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->compression_toggle),
+ compression_toggle = gtk_frame_get_label_widget (GTK_FRAME (dialog->compression_frame));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (compression_toggle),
gimp_image_get_xcf_compression (image));
+ /* Force a "toggled" signal since gtk_toggle_button_set_active() won't
+ * send it if the button status doesn't change.
+ */
+ gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (compression_toggle));
if (ext_file)
{
@@ -336,28 +315,42 @@ gimp_save_dialog_set_image (GimpSaveDialog *dialog,
/* private functions */
static void
-gimp_save_dialog_add_compression_toggle (GimpSaveDialog *dialog)
+gimp_save_dialog_add_extra_widgets (GimpSaveDialog *dialog)
{
- GtkWidget *frame;
+ GtkWidget *label;
+ GtkWidget *reasons;
+ GtkWidget *compression_toggle;
- dialog->compression_toggle =
+ /* Compression toggle. */
+ compression_toggle =
gtk_check_button_new_with_label (_("Save this XCF file with better but slower compression"));
- 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,
+ dialog->compression_frame = gimp_frame_new (NULL);
+ gtk_frame_set_label_widget (GTK_FRAME (dialog->compression_frame), compression_toggle);
+ gtk_widget_show (compression_toggle);
+ gimp_file_dialog_add_extra_widget (GIMP_FILE_DIALOG (dialog), dialog->compression_frame,
FALSE, FALSE, 0);
- gtk_widget_show (frame);
+ gtk_widget_show (dialog->compression_frame);
/* 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 (frame), dialog->compat_info);
-
- g_signal_connect (dialog->compression_toggle, "toggled",
+ dialog->compat_info = gtk_expander_new (NULL);
+ label = gtk_label_new ("");
+ gtk_expander_set_label_widget (GTK_EXPANDER (dialog->compat_info), label);
+ gtk_widget_show (label);
+ gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+
+ reasons = gtk_text_view_new ();
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (reasons), FALSE);
+ gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (reasons), FALSE);
+ gtk_container_add (GTK_CONTAINER (dialog->compat_info), reasons);
+ gtk_widget_show (reasons);
+
+ gimp_file_dialog_add_extra_widget (GIMP_FILE_DIALOG (dialog),
+ dialog->compat_info,
+ FALSE, FALSE, 0);
+ gtk_widget_show (dialog->compat_info);
+
+ g_signal_connect (compression_toggle, "toggled",
G_CALLBACK (gimp_save_dialog_compression_toggled),
dialog);
}
@@ -366,7 +359,64 @@ static void
gimp_save_dialog_compression_toggled (GtkToggleButton *button,
GimpSaveDialog *dialog)
{
+ const gchar *version_string = NULL;
+ GimpFileDialog *file_dialog = GIMP_FILE_DIALOG (dialog);
+ gchar *compat_hint = NULL;
+ gchar *reason = NULL;
+ GtkWidget *widget;
+ GtkTextBuffer *text_buffer;
+ gint version;
+
+ if (! file_dialog->image)
+ return;
+
dialog->compression = gtk_toggle_button_get_active (button);
+
+ if (dialog->compression)
+ gimp_image_get_xcf_version (file_dialog->image, TRUE, &version,
+ &version_string, &reason);
+ else
+ gimp_image_get_xcf_version (file_dialog->image, FALSE, &version,
+ &version_string, &reason);
+
+ /* Only show compatibility information for GIMP over 2.6. The reason
+ * is mostly that we don't have details to make a compatibility list
+ * with this older version.
+ * It's anyway so prehistorical that we are not really caring about
+ * compatibility with older version.
+ */
+ if (version <= 206)
+ gtk_widget_hide (dialog->compat_info);
+ else
+ gtk_widget_show (dialog->compat_info);
+
+ /* Set the compatibility label. */
+ compat_hint =
+ g_strdup_printf (_("The image uses features from %s and "
+ "won't be readable by older GIMP versions."),
+ version_string);
+
+ if (gimp_image_get_metadata (file_dialog->image))
+ {
+ gchar *temp_hint;
+
+ temp_hint = g_strconcat (compat_hint, "\n",
+ _("Metadata won't be visible in GIMP "
+ "older than version 2.10."), NULL);
+ g_free (compat_hint);
+ compat_hint = temp_hint;
+ }
+
+ widget = gtk_expander_get_label_widget (GTK_EXPANDER (dialog->compat_info));
+ gtk_label_set_text (GTK_LABEL (widget), compat_hint);
+ g_free (compat_hint);
+
+ /* Fill in the details (list of compatibility reasons). */
+ widget = gtk_bin_get_child (GTK_BIN (dialog->compat_info));
+ text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget));
+ gtk_text_buffer_set_text (text_buffer, reason ? reason : "", -1);
+ if (reason)
+ g_free (reason);
}
static GimpSaveDialogState *
diff --git a/app/widgets/gimpsavedialog.h b/app/widgets/gimpsavedialog.h
index 94d3c4bad1..1966e8ee21 100644
--- a/app/widgets/gimpsavedialog.h
+++ b/app/widgets/gimpsavedialog.h
@@ -43,7 +43,7 @@ struct _GimpSaveDialog
gboolean close_after_saving;
GimpObject *display_to_close;
- GtkWidget *compression_toggle;
+ GtkWidget *compression_frame;
GtkWidget *compat_info;
gboolean compression;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]