Reset button for {Resize,Scale}-{Layer,Image} dialog

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

 



Hi there,
today I worked a bit on a web page and I used the resizing dialogs quite
a lot. I found it really annoying that there was no "Reset" button
available - if you happen to forget to "unchain" the X and Y ratio, you
have to enter 100% or close and reopen the dialog.

Therefore I went on, had a look at app/resize.c and added such a button.

I've attached the patch but please have a look at it - I only used GTK
once with Python and Glade before but never with plain C. Neither have
I contributed to GIMP before.

<tiny rant>
The source documentation is virtually non-existant. E.g. I would
appreciate several lines of explanations in front of each file stating
what it is for and giving some clues about the implementation, do's and
do not's, hints, FIXMEs, TODOs etc.
For example it was not too obvious that resize.c contains code for the
resizing as well as scaling dialogs.
</tiny rant>

Bye, Tino.

-- 
             * LINUX - Where do you want to be tomorrow? *
--- gimp-1.1.27.org/app/resize.c	Mon Oct  9 21:17:02 2000
+++ gimp-1.1.27/app/resize.c	Mon Oct  9 22:24:33 2000
@@ -71,13 +71,15 @@
 static gint  resize_bound_off_x          (Resize *, gint);
 static gint  resize_bound_off_y          (Resize *, gint);
 static void  orig_labels_update          (GtkWidget *, gpointer);
+static void  reset_callback              (GtkWidget *, gpointer);
 static void  size_callback               (GtkWidget *, gpointer);
 static void  ratio_callback              (GtkWidget *, gpointer);
 static void  size_update                 (Resize *, gdouble, gdouble, gdouble, gdouble);
 static void  offset_update               (GtkWidget *, gpointer);
 static gint  resize_events               (GtkWidget *, GdkEvent *);
 static void  printsize_update            (GtkWidget *, gpointer);
-static void  resolution_update           (GtkWidget *, gpointer);
+static void  resolution_callback         (GtkWidget *, gpointer);
+static void  resolution_update           (Resize *, gdouble, gdouble);
 static void  resize_scale_warn_callback  (GtkWidget *, gboolean, gpointer);
 
 Resize *
@@ -191,6 +193,10 @@
 
 		       _("OK"), ok_cb,
 		       user_data, NULL, NULL, TRUE, FALSE,
+
+		       _("Reset"), reset_callback,
+		       resize, NULL, NULL, FALSE, TRUE,
+
 		       _("Cancel"), cancel_cb ? cancel_cb : gtk_widget_destroy,
 		       cancel_cb ? user_data : NULL,
 		       cancel_cb ? NULL : (gpointer) 1,
@@ -611,7 +617,7 @@
 				  1, resize->resolution_y);
 
       gtk_signal_connect (GTK_OBJECT (private->resolution_se), "value_changed",
-			  (GtkSignalFunc) resolution_update,
+			  (GtkSignalFunc) resolution_callback,
 			  resize);
 
       /*  the resolution chainbutton  */
@@ -839,6 +845,31 @@
     }
 }
 
+/*
+ * Callback function for "Reset" button.
+ * Data must be a pointer pointer to a Resize structure.
+ */
+static void
+reset_callback (GtkWidget *widget,
+                gpointer data)
+{
+  Resize *resize;
+  ResizePrivate *private;
+
+  resize = (Resize *)data;
+  private = (ResizePrivate *)resize->private_part;
+
+  /* restore size and ratio settings */
+  size_update (resize, private->old_width, private->old_height, 1.0, 1.0);
+
+  if ((resize->type == ScaleWidget) && (resize->target == ResizeImage))
+    {
+      /* restore resolution settings */
+      resolution_update (resize, private->old_res_x, private->old_res_y);
+    }
+
+}
+  
 static void
 size_callback (GtkWidget *widget,
 	       gpointer   data)
@@ -1064,8 +1095,9 @@
 				      resize);
 }
 
+/* Callback for resolution change. */
 static void
-resolution_update (GtkWidget *widget,
+resolution_callback (GtkWidget *widget,
 		   gpointer   data)
 {
   Resize *resize;
@@ -1092,6 +1124,17 @@
 	  res_x = res_y;
 	}
     }
+
+  resolution_update (resize, res_x, res_y);
+}
+
+/* Update widgets with resolution settings found in given Resize struct. */
+static void
+resolution_update (Resize *resize, gdouble res_x, gdouble res_y)
+{
+  ResizePrivate *private;
+
+  private = (ResizePrivate *) resize->private_part;
 
   resize->resolution_x = res_x;
   resize->resolution_y = res_y;

[Index of Archives]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [GIMP for Windows]     [KDE]     [GEGL]     [Gimp's Home]     [Gimp on GUI]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux