[gimp] app: make file_save() aware of the difference between overwrite and export



commit 39c18e9a48ccc37710d4b0074d520be70f9a95a3
Author: Michael Natterer <mitch gimp org>
Date:   Fri May 18 18:48:51 2012 +0200

    app: make file_save() aware of the difference between overwrite and export
    
    by having two booleans "export_backward" and "export_forward" in the
    api instead of just an "export" one that would destroy the "imported
    from" state. This change fixes the state of the "Overwrite" menu item,
    so it stays visible until the file got either saved or exported to
    another filename.
    
    This also reverts commit a4beeecf2b6f42659bdffac8b3795abfb18eee34, so
    Ctrl-S is always invokable even if invisible.

 app/actions/file-actions.c     |    2 +-
 app/actions/file-commands.c    |   13 ++++++++++---
 app/dialogs/file-save-dialog.c |    8 ++++++--
 app/dialogs/file-save-dialog.h |    3 ++-
 app/file/file-save.c           |   17 ++++++++++++++---
 app/file/file-save.h           |    3 ++-
 app/widgets/gimpdnd-xds.c      |    3 ++-
 7 files changed, 37 insertions(+), 12 deletions(-)
---
diff --git a/app/actions/file-actions.c b/app/actions/file-actions.c
index b4a16ac..45185a2 100644
--- a/app/actions/file-actions.c
+++ b/app/actions/file-actions.c
@@ -280,7 +280,7 @@ file_actions_update (GimpActionGroup *group,
   SET_SENSITIVE ("file-save-as",         drawable);
   SET_SENSITIVE ("file-save-a-copy",     drawable);
   SET_SENSITIVE ("file-revert",          image && (gimp_image_get_uri (image) || source));
-  SET_SENSITIVE ("file-export-to",       drawable && ! show_overwrite);
+  SET_SENSITIVE ("file-export-to",       drawable);
   SET_VISIBLE   ("file-export-to",       ! show_overwrite);
   SET_SENSITIVE ("file-overwrite",       show_overwrite);
   SET_VISIBLE   ("file-overwrite",       show_overwrite);
diff --git a/app/actions/file-commands.c b/app/actions/file-commands.c
index 93ee58c..830407d 100644
--- a/app/actions/file-commands.c
+++ b/app/actions/file-commands.c
@@ -252,7 +252,7 @@ file_save_cmd_callback (GtkAction *action,
                                                    gimp, image, uri,
                                                    save_proc,
                                                    GIMP_RUN_WITH_LAST_VALS,
-                                                   TRUE, FALSE, TRUE);
+                                                   TRUE, FALSE, FALSE, TRUE);
               break;
             }
 
@@ -288,8 +288,9 @@ file_save_cmd_callback (GtkAction *action,
       {
         const gchar         *uri = NULL;
         GimpPlugInProcedure *export_proc;
+        gboolean             overwrite;
 
-        if (save_mode == GIMP_SAVE_MODE_EXPORT_TO) 
+        if (save_mode == GIMP_SAVE_MODE_EXPORT_TO)
           {
             uri = gimp_image_get_exported_uri (image);
 
@@ -299,10 +300,14 @@ file_save_cmd_callback (GtkAction *action,
                 file_export_dialog_show (gimp, image, widget);
                 break;
               }
+
+            overwrite = FALSE;
           }
         else if (save_mode == GIMP_SAVE_MODE_OVERWRITE)
           {
             uri = gimp_image_get_imported_uri (image);
+
+            overwrite = TRUE;
           }
 
         if (uri)
@@ -327,7 +332,9 @@ file_save_cmd_callback (GtkAction *action,
                                                  gimp, image, uri_copy,
                                                  export_proc,
                                                  GIMP_RUN_WITH_LAST_VALS,
-                                                 FALSE, TRUE, TRUE);
+                                                 FALSE,
+                                                 overwrite, ! overwrite,
+                                                 TRUE);
             g_free (uri_copy);
           }
       }
diff --git a/app/dialogs/file-save-dialog.c b/app/dialogs/file-save-dialog.c
index fdb413b..148df91 100644
--- a/app/dialogs/file-save-dialog.c
+++ b/app/dialogs/file-save-dialog.c
@@ -191,6 +191,7 @@ file_save_dialog_response (GtkWidget *save_dialog,
                                        save_proc,
                                        GIMP_RUN_INTERACTIVE,
                                        ! dialog->save_a_copy && ! dialog->export,
+                                       FALSE,
                                        dialog->export,
                                        FALSE))
         {
@@ -629,7 +630,8 @@ file_save_dialog_save_image (GimpProgress        *progress,
                              GimpPlugInProcedure *save_proc,
                              GimpRunMode          run_mode,
                              gboolean             change_saved_state,
-                             gboolean             export,
+                             gboolean             export_backward,
+                             gboolean             export_forward,
                              gboolean             verbose_cancel)
 {
   GimpPDBStatusType  status;
@@ -645,7 +647,9 @@ file_save_dialog_save_image (GimpProgress        *progress,
     }
 
   status = file_save (gimp, image, progress, uri,
-                      save_proc, run_mode, change_saved_state, export, &error);
+                      save_proc, run_mode,
+                      change_saved_state, export_backward, export_forward,
+                      &error);
 
   switch (status)
     {
diff --git a/app/dialogs/file-save-dialog.h b/app/dialogs/file-save-dialog.h
index abf1b07..70934a0 100644
--- a/app/dialogs/file-save-dialog.h
+++ b/app/dialogs/file-save-dialog.h
@@ -29,7 +29,8 @@ gboolean    file_save_dialog_save_image (GimpProgress        *progress_and_handl
                                          GimpPlugInProcedure *write_proc,
                                          GimpRunMode          run_mode,
                                          gboolean             save_a_copy,
-                                         gboolean             export,
+                                         gboolean             export_backward,
+                                         gboolean             export_forward,
                                          gboolean             verbose_cancel);
 
 
diff --git a/app/file/file-save.c b/app/file/file-save.c
index cdb2415..3dd6bf0 100644
--- a/app/file/file-save.c
+++ b/app/file/file-save.c
@@ -76,7 +76,8 @@ file_save (Gimp                *gimp,
            GimpPlugInProcedure *file_proc,
            GimpRunMode          run_mode,
            gboolean             change_saved_state,
-           gboolean             export,
+           gboolean             export_backward,
+           gboolean             export_forward,
            GError             **error)
 {
   GimpDrawable      *drawable;
@@ -93,6 +94,8 @@ file_save (Gimp                *gimp,
   g_return_val_if_fail (uri != NULL, GIMP_PDB_CALLING_ERROR);
   g_return_val_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (file_proc),
                         GIMP_PDB_CALLING_ERROR);
+  g_return_val_if_fail ((export_backward && export_forward) == FALSE,
+                        GIMP_PDB_CALLING_ERROR);
   g_return_val_if_fail (error == NULL || *error == NULL,
                         GIMP_PDB_CALLING_ERROR);
 
@@ -170,7 +173,15 @@ file_save (Gimp                *gimp,
 
           gimp_image_clean_all (image);
         }
-      else if (export)
+      else if (export_backward)
+        {
+          /* We exported the image back to its imported source,
+           * change nothing about export/import flags, only set
+           * the export state to clean
+           */
+          gimp_image_export_clean_all (image);
+        }
+      else if (export_forward)
         {
           /* Remeber the last entered Export URI for the image. We
            * only need to do this explicitly when exporting. It
@@ -188,7 +199,7 @@ file_save (Gimp                *gimp,
           gimp_image_export_clean_all (image);
         }
 
-      if (export)
+      if (export_backward || export_forward)
         gimp_image_exported (image, uri);
       else
         gimp_image_saved (image, uri);
diff --git a/app/file/file-save.h b/app/file/file-save.h
index 9596a72..df6027f 100644
--- a/app/file/file-save.h
+++ b/app/file/file-save.h
@@ -28,7 +28,8 @@ GimpPDBStatusType   file_save (Gimp                 *gimp,
                                GimpPlugInProcedure  *file_proc,
                                GimpRunMode           run_mode,
                                gboolean              change_saved_state,
-                               gboolean              export,
+                               gboolean              export_backward,
+                               gboolean              export_forward,
                                GError              **error);
 
 
diff --git a/app/widgets/gimpdnd-xds.c b/app/widgets/gimpdnd-xds.c
index 6dc4921..5c65d14 100644
--- a/app/widgets/gimpdnd-xds.c
+++ b/app/widgets/gimpdnd-xds.c
@@ -164,7 +164,8 @@ gimp_dnd_xds_save_image (GdkDragContext   *context,
         {
           if (file_save (image->gimp,
                          image, NULL,
-                         uri, proc, GIMP_RUN_INTERACTIVE, TRUE, export,
+                         uri, proc, GIMP_RUN_INTERACTIVE,
+                         ! export, FALSE, export,
                          &error) == GIMP_PDB_SUCCESS)
             {
               gtk_selection_data_set (selection,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]