[gimp: 5/27] app: Support File -> Revert of imported images



commit e3f57fbd38e20b6eb671cd996f61a66c2e57d0ff
Author: Martin Nordholts <martinn src gnome org>
Date:   Sun Apr 26 13:00:25 2009 +0200

    app: Support File -> Revert of imported images
    
    If a file has not been saved yet but was imported from some other
    image, revert to that image.
---
 app/actions/file-commands.c |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/app/actions/file-commands.c b/app/actions/file-commands.c
index 796c4ee..9132553 100644
--- a/app/actions/file-commands.c
+++ b/app/actions/file-commands.c
@@ -312,16 +312,24 @@ file_revert_cmd_callback (GtkAction *action,
   GimpDisplay *display;
   GimpImage   *image;
   GtkWidget   *dialog;
-  const gchar *uri;
+  const gchar *uri    = NULL;
+  const gchar *source = NULL;
   return_if_no_display (display, data);
 
   image = display->image;
 
   uri = gimp_object_get_name (GIMP_OBJECT (image));
 
+  if (! uri)
+    {
+      uri    = g_object_get_data (G_OBJECT (image),
+                                  GIMP_FILE_IMPORT_SOURCE_URI_KEY);
+      source = uri;
+    }
+
   dialog = g_object_get_data (G_OBJECT (image), REVERT_DATA_KEY);
 
-  if (! uri)
+  if (! uri && ! source)
     {
       gimp_message_literal (image->gimp,
 			    G_OBJECT (display), GIMP_MESSAGE_ERROR,
@@ -360,7 +368,11 @@ file_revert_cmd_callback (GtkAction *action,
                         G_CALLBACK (file_revert_confirm_response),
                         display);
 
-      basename = file_utils_uri_display_basename (uri);
+      if (! source)
+        basename = file_utils_uri_display_basename (uri);
+      else
+        basename = g_strdup (gimp_image_get_uri (image));
+
       filename = file_utils_uri_display_name (uri);
 
       gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box,
@@ -556,6 +568,10 @@ file_revert_confirm_response (GtkWidget   *dialog,
 
       uri = gimp_object_get_name (GIMP_OBJECT (old_image));
 
+      if (! uri)
+        uri = g_object_get_data (G_OBJECT (old_image),
+                                 GIMP_FILE_IMPORT_SOURCE_URI_KEY);
+
       new_image = file_open_image (gimp, gimp_get_user_context (gimp),
                                    GIMP_PROGRESS (display),
                                    uri, uri, FALSE, NULL,



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