[gimp] all: same changes as in the last commit, for the convert precision dialog



commit 34d96a3a87e6cb95150dff273505b328851b4529
Author: Michael Natterer <mitch gimp org>
Date:   Sun Jun 15 22:19:33 2014 +0200

    all: same changes as in the last commit, for the convert precision dialog

 app/actions/image-commands.c |   28 ++++++++++++++++------------
 1 files changed, 16 insertions(+), 12 deletions(-)
---
diff --git a/app/actions/image-commands.c b/app/actions/image-commands.c
index 7d50527..b24ea86 100644
--- a/app/actions/image-commands.c
+++ b/app/actions/image-commands.c
@@ -181,7 +181,8 @@ image_convert_base_type_cmd_callback (GtkAction *action,
   if (value == gimp_image_get_base_type (image))
     return;
 
-  dialog = g_object_get_data (G_OBJECT (image), IMAGE_CONVERT_TYPE_DIALOG_KEY);
+  dialog = g_object_get_data (G_OBJECT (image),
+                              IMAGE_CONVERT_TYPE_DIALOG_KEY);
 
   switch (value)
     {
@@ -229,9 +230,9 @@ image_convert_base_type_cmd_callback (GtkAction *action,
 }
 
 static void
-image_convert_precision_dialog_unset (GtkWidget *widget)
+image_convert_precision_dialog_unset (GimpImage *image)
 {
-  g_object_set_data (G_OBJECT (widget), IMAGE_CONVERT_PRECISION_DIALOG_KEY, NULL);
+  g_object_set_data (G_OBJECT (image), IMAGE_CONVERT_PRECISION_DIALOG_KEY, NULL);
 }
 
 void
@@ -240,26 +241,25 @@ image_convert_precision_cmd_callback (GtkAction *action,
                                       gpointer   data)
 {
   GimpImage     *image;
-  GtkWidget     *widget;
   GimpDisplay   *display;
+  GtkWidget     *widget;
+  GtkWidget     *dialog;
   GimpPrecision  value;
   return_if_no_image (image, data);
-  return_if_no_widget (widget, data);
   return_if_no_display (display, data);
+  return_if_no_widget (widget, data);
 
   value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
 
   if (value == gimp_image_get_precision (image))
     return;
 
+  dialog = g_object_get_data (G_OBJECT (image),
+                              IMAGE_CONVERT_PRECISION_DIALOG_KEY);
+
   if ((value < gimp_image_get_precision (image)) ||
       (gimp_babl_component_type (value) == gimp_image_get_component_type (image)))
     {
-      GtkWidget *dialog;
-
-      dialog = g_object_get_data (G_OBJECT (widget),
-                                  IMAGE_CONVERT_PRECISION_DIALOG_KEY);
-
       if (! dialog)
         {
           dialog = convert_precision_dialog_new (image,
@@ -268,22 +268,26 @@ image_convert_precision_cmd_callback (GtkAction *action,
                                                  value,
                                                  GIMP_PROGRESS (display));
 
-          g_object_set_data (G_OBJECT (widget),
+          g_object_set_data (G_OBJECT (image),
                              IMAGE_CONVERT_PRECISION_DIALOG_KEY, dialog);
 
           g_signal_connect_object (dialog, "destroy",
                                    G_CALLBACK (image_convert_precision_dialog_unset),
-                                   widget, G_CONNECT_SWAPPED);
+                                   image, G_CONNECT_SWAPPED);
         }
 
       gtk_window_present (GTK_WINDOW (dialog));
     }
   else
     {
+      if (dialog)
+        gtk_widget_destroy (dialog);
+
       gimp_image_convert_precision (image, value, 0, 0, 0,
                                     GIMP_PROGRESS (display));
     }
 
+  /*  see comment above  */
   gimp_image_flush (image);
 }
 


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