From e2d8f7e48d5281e6a03f7baf394a36e743311656 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Mon, 13 Sep 2004 21:58:27 +0000 Subject: [PATCH] make the "Save EXIF data" toggle insensitive when no EXIF data is present 2004-09-13 Sven Neumann * plug-ins/common/jpeg.c (save_dialog): make the "Save EXIF data" toggle insensitive when no EXIF data is present (bug #140042). * app/display/gimpdisplayshell-close.c: as suggested by the HIG, ask the user to save the image when the last display is being closed. Addresses some issues raised in bug #106726. --- ChangeLog | 9 ++ app/display/gimpdisplayshell-close.c | 87 ++++++++++++++++--- devel-docs/libgimpbase/tmpl/gimpprotocol.sgml | 6 +- plug-ins/common/jpeg.c | 4 +- plug-ins/jpeg/jpeg-load.c | 4 +- plug-ins/jpeg/jpeg-load.h | 4 +- plug-ins/jpeg/jpeg-save.c | 4 +- plug-ins/jpeg/jpeg-save.h | 4 +- plug-ins/jpeg/jpeg.c | 4 +- plug-ins/jpeg/jpeg.h | 4 +- 10 files changed, 105 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8d96490948..5bc77dd3b2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2004-09-13 Sven Neumann + + * plug-ins/common/jpeg.c (save_dialog): make the "Save EXIF data" + toggle insensitive when no EXIF data is present (bug #140042). + + * app/display/gimpdisplayshell-close.c: as suggested by the HIG, + ask the user to save the image when the last display is being + closed. Addresses some issues raised in bug #106726. + 2004-09-13 Michael Natterer * app/app_procs.c (app_run): install the message handler for the diff --git a/app/display/gimpdisplayshell-close.c b/app/display/gimpdisplayshell-close.c index fd3f2a43bf..3a780ae289 100644 --- a/app/display/gimpdisplayshell-close.c +++ b/app/display/gimpdisplayshell-close.c @@ -33,6 +33,7 @@ #include "widgets/gimphelp-ids.h" #include "widgets/gimpmessagebox.h" +#include "widgets/gimpuimanager.h" #include "gimpdisplay.h" #include "gimpdisplayshell.h" @@ -43,11 +44,13 @@ /* local function prototypes */ -static void gimp_display_shell_close_dialog (GimpDisplayShell *shell, - GimpImage *gimage); -static void gimp_display_shell_close_response (GtkWidget *widget, - gboolean close, - GimpDisplayShell *shell); +static void gimp_display_shell_close_dialog (GimpDisplayShell *shell, + GimpImage *gimage); +static void gimp_display_shell_close_name_changed (GimpImage *image, + GtkWidget *dialog); +static void gimp_display_shell_close_response (GtkWidget *widget, + gboolean close, + GimpDisplayShell *shell); /* public functions */ @@ -88,6 +91,9 @@ gimp_display_shell_close (GimpDisplayShell *shell, /* private functions */ +#define RESPONSE_SAVE 1 + + static void gimp_display_shell_close_dialog (GimpDisplayShell *shell, GimpImage *gimage) @@ -105,7 +111,8 @@ gimp_display_shell_close_dialog (GimpDisplayShell *shell, name = file_utils_uri_to_utf8_basename (gimp_image_get_uri (gimage)); - title = g_strdup_printf (_("Close %s?"), name); + title = g_strdup_printf (_("Close %s"), name); + g_free (name); shell->close_dialog = dialog = gimp_dialog_new (title, @@ -114,13 +121,16 @@ gimp_display_shell_close_dialog (GimpDisplayShell *shell, gimp_standard_help_func, GIMP_HELP_FILE_CLOSE_CONFIRM, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - _("_Discard changes"), GTK_RESPONSE_OK, + _("_Close without Saving"), GTK_RESPONSE_CLOSE, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_SAVE, RESPONSE_SAVE, NULL); g_free (title); + gtk_dialog_set_default_response (GTK_DIALOG (dialog), RESPONSE_SAVE); + g_signal_connect (dialog, "destroy", G_CALLBACK (gtk_widget_destroyed), &shell->close_dialog); @@ -134,17 +144,41 @@ gimp_display_shell_close_dialog (GimpDisplayShell *shell, gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), box); gtk_widget_show (box); - gimp_message_box_set_primary_text (GIMP_MESSAGE_BOX (box), - _("Changes were made to '%s'."), name); + g_object_set_data (G_OBJECT (dialog), "message-box", box); - g_free (name); + g_signal_connect_object (gimage, "name_changed", + G_CALLBACK (gimp_display_shell_close_name_changed), + dialog, 0); + + gimp_display_shell_close_name_changed (gimage, dialog); gimp_message_box_set_text (GIMP_MESSAGE_BOX (box), - _("Unsaved changes will be lost.")); + _("If you don't save the image, " + "changes will be lost.")); gtk_widget_show (dialog); } +static void +gimp_display_shell_close_name_changed (GimpImage *image, + GtkWidget *dialog) +{ + GtkWidget *box = g_object_get_data (G_OBJECT (dialog), "message-box"); + gchar *name; + gchar *title; + + name = file_utils_uri_to_utf8_basename (gimp_image_get_uri (image)); + + title = g_strdup_printf (_("Close %s"), name); + gtk_window_set_title (GTK_WINDOW (dialog), title); + g_free (title); + + gimp_message_box_set_primary_text (GIMP_MESSAGE_BOX (box), + _("Save the changes to image '%s' " + "before closing?"), name); + g_free (name); +} + static void gimp_display_shell_close_response (GtkWidget *widget, gint response_id, @@ -152,6 +186,31 @@ gimp_display_shell_close_response (GtkWidget *widget, { gtk_widget_destroy (widget); - if (response_id == GTK_RESPONSE_OK) - gimp_display_delete (shell->gdisp); + switch (response_id) + { + case GTK_RESPONSE_CLOSE: + gimp_display_delete (shell->gdisp); + break; + + case RESPONSE_SAVE: + { + GimpActionGroup *group; + GtkAction *action; + + group = gimp_ui_manager_get_action_group (shell->menubar_manager, + "file"); + action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), + "file-save"); + g_return_if_fail (action != NULL); + + gtk_action_activate (action); + + if (! shell->gdisp->gimage->dirty) + gimp_display_delete (shell->gdisp); + } + break; + + default: + break; + } } diff --git a/devel-docs/libgimpbase/tmpl/gimpprotocol.sgml b/devel-docs/libgimpbase/tmpl/gimpprotocol.sgml index 3e97cdd0d0..fc50ea8f52 100644 --- a/devel-docs/libgimpbase/tmpl/gimpprotocol.sgml +++ b/devel-docs/libgimpbase/tmpl/gimpprotocol.sgml @@ -31,8 +31,8 @@ The communication protocol between GIMP and it's plug-ins. @tile_width: @tile_height: @shm_ID: -@gimp_reserved_1: -@gimp_reserved_2: +@check_size: +@check_type: @gimp_reserved_3: @gimp_reserved_4: @gimp_reserved_5: @@ -41,8 +41,6 @@ The communication protocol between GIMP and it's plug-ins. @gimp_reserved_8: @install_cmap: @show_tool_tips: -@check_size: -@check_type: @min_colors: @gdisp_ID: @app_name: diff --git a/plug-ins/common/jpeg.c b/plug-ins/common/jpeg.c index b9827e019e..45cd8a298c 100644 --- a/plug-ins/common/jpeg.c +++ b/plug-ins/common/jpeg.c @@ -1913,7 +1913,9 @@ save_dialog (void) &jsvals.save_exif); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (exif_toggle), - jsvals.save_exif); + jsvals.save_exif && exif_data); + + gtk_widget_set_sensitive (exif_toggle, exif_data != NULL); #endif /* Subsampling */ diff --git a/plug-ins/jpeg/jpeg-load.c b/plug-ins/jpeg/jpeg-load.c index b9827e019e..45cd8a298c 100644 --- a/plug-ins/jpeg/jpeg-load.c +++ b/plug-ins/jpeg/jpeg-load.c @@ -1913,7 +1913,9 @@ save_dialog (void) &jsvals.save_exif); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (exif_toggle), - jsvals.save_exif); + jsvals.save_exif && exif_data); + + gtk_widget_set_sensitive (exif_toggle, exif_data != NULL); #endif /* Subsampling */ diff --git a/plug-ins/jpeg/jpeg-load.h b/plug-ins/jpeg/jpeg-load.h index b9827e019e..45cd8a298c 100644 --- a/plug-ins/jpeg/jpeg-load.h +++ b/plug-ins/jpeg/jpeg-load.h @@ -1913,7 +1913,9 @@ save_dialog (void) &jsvals.save_exif); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (exif_toggle), - jsvals.save_exif); + jsvals.save_exif && exif_data); + + gtk_widget_set_sensitive (exif_toggle, exif_data != NULL); #endif /* Subsampling */ diff --git a/plug-ins/jpeg/jpeg-save.c b/plug-ins/jpeg/jpeg-save.c index b9827e019e..45cd8a298c 100644 --- a/plug-ins/jpeg/jpeg-save.c +++ b/plug-ins/jpeg/jpeg-save.c @@ -1913,7 +1913,9 @@ save_dialog (void) &jsvals.save_exif); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (exif_toggle), - jsvals.save_exif); + jsvals.save_exif && exif_data); + + gtk_widget_set_sensitive (exif_toggle, exif_data != NULL); #endif /* Subsampling */ diff --git a/plug-ins/jpeg/jpeg-save.h b/plug-ins/jpeg/jpeg-save.h index b9827e019e..45cd8a298c 100644 --- a/plug-ins/jpeg/jpeg-save.h +++ b/plug-ins/jpeg/jpeg-save.h @@ -1913,7 +1913,9 @@ save_dialog (void) &jsvals.save_exif); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (exif_toggle), - jsvals.save_exif); + jsvals.save_exif && exif_data); + + gtk_widget_set_sensitive (exif_toggle, exif_data != NULL); #endif /* Subsampling */ diff --git a/plug-ins/jpeg/jpeg.c b/plug-ins/jpeg/jpeg.c index b9827e019e..45cd8a298c 100644 --- a/plug-ins/jpeg/jpeg.c +++ b/plug-ins/jpeg/jpeg.c @@ -1913,7 +1913,9 @@ save_dialog (void) &jsvals.save_exif); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (exif_toggle), - jsvals.save_exif); + jsvals.save_exif && exif_data); + + gtk_widget_set_sensitive (exif_toggle, exif_data != NULL); #endif /* Subsampling */ diff --git a/plug-ins/jpeg/jpeg.h b/plug-ins/jpeg/jpeg.h index b9827e019e..45cd8a298c 100644 --- a/plug-ins/jpeg/jpeg.h +++ b/plug-ins/jpeg/jpeg.h @@ -1913,7 +1913,9 @@ save_dialog (void) &jsvals.save_exif); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (exif_toggle), - jsvals.save_exif); + jsvals.save_exif && exif_data); + + gtk_widget_set_sensitive (exif_toggle, exif_data != NULL); #endif /* Subsampling */