Index: gimplevelstool.c
===================================================================
RCS file: /cvs/gnome/gimp/app/tools/gimplevelstool.c,v
retrieving revision 1.96
diff -u -r1.96 gimplevelstool.c
--- gimplevelstool.c	16 Jun 2002 17:13:37 -0000	1.96
+++ gimplevelstool.c	11 Jul 2002 21:02:51 -0000
@@ -148,14 +148,18 @@
 						    gpointer       data);
 static gboolean levels_set_sensitive_callback      (gpointer       item_data,
                                                     LevelsDialog  *ld);
-static void   levels_reset_callback                (GtkWidget     *widget,
-						    gpointer       data);
 static void   levels_ok_callback                   (GtkWidget     *widget,
 						    gpointer       data);
 static void   levels_cancel_callback               (GtkWidget     *widget,
 						    gpointer       data);
+static void   levels_reset_callback                (GtkWidget     *widget,
+						    gpointer       data);
 static void   levels_auto_callback                 (GtkWidget     *widget,
 						    gpointer       data);
+static void   levels_reset_all_callback            (GtkWidget     *widget,
+						    gpointer       data);
+static void   levels_auto_all_callback             (GtkWidget     *widget,
+						    gpointer       data);
 static void   levels_load_callback                 (GtkWidget     *widget,
 						    gpointer       data);
 static void   levels_save_callback                 (GtkWidget     *widget,
@@ -387,6 +391,7 @@
   GtkWidget *hbbox;
   GtkWidget *button;
   GtkWidget *spinbutton;
+  GtkWidget *tabbedarea;
   GtkObject *data;
 
   ld = g_new0 (LevelsDialog, 1);
@@ -401,9 +406,6 @@
 			       GTK_WIN_POS_NONE,
 			       FALSE, TRUE, FALSE,
 
-			       GIMP_STOCK_RESET, levels_reset_callback,
-			       ld, NULL, NULL, FALSE, FALSE,
-
 			       GTK_STOCK_CANCEL, levels_cancel_callback,
 			       ld, NULL, NULL, FALSE, TRUE,
 
@@ -416,16 +418,9 @@
   gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 4);
   gtk_container_add (GTK_CONTAINER (GTK_DIALOG (ld->shell)->vbox), main_vbox);
 
-  hbox = gtk_hbox_new (TRUE, 0);
-  gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
-  gtk_widget_show (hbox);
-
-  vbox = gtk_vbox_new (FALSE, 4);
-  gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
-
   /*  The option menu for selecting channels  */
   channel_hbox = gtk_hbox_new (FALSE, 4);
-  gtk_box_pack_start (GTK_BOX (vbox), channel_hbox, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (main_vbox), channel_hbox, FALSE, FALSE, 0);
 
   label = gtk_label_new (_("Modify Levels for Channel:"));
   gtk_box_pack_start (GTK_BOX (channel_hbox), label, FALSE, FALSE, 0);
@@ -441,6 +436,29 @@
 
   gtk_widget_show (channel_hbox);
 
+  tabbedarea = gtk_frame_new(_("This channel:"));
+  gtk_box_pack_start (GTK_BOX (main_vbox), tabbedarea, FALSE, FALSE, 0);
+  vbox = gtk_vbox_new (FALSE, 4);
+  gtk_container_add (GTK_CONTAINER (tabbedarea), vbox);
+
+  /*  The levels histogram  */
+  hbox = gtk_hbox_new (TRUE, 2);
+  gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, FALSE, 0);
+
+  frame = gtk_frame_new (NULL);
+  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
+  gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, FALSE, 0);
+  ld->histogram = gimp_histogram_view_new (HISTOGRAM_WIDTH, HISTOGRAM_HEIGHT);
+  gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (ld->histogram));
+
+  /* ignore button_events, since we don't want the user to be able to set the range */
+  gtk_widget_set_events (GTK_WIDGET (ld->histogram), 
+			 (GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK));
+
+  gtk_widget_show (GTK_WIDGET (ld->histogram));
+  gtk_widget_show (frame);
+  gtk_widget_show (hbox);
+
   /*  Horizontal box for input levels spinbuttons  */
   hbox = gtk_hbox_new (FALSE, 4);
   gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
@@ -495,24 +513,6 @@
   gtk_widget_show (spinbutton);
   gtk_widget_show (hbox);
 
-  /*  The levels histogram  */
-  hbox = gtk_hbox_new (TRUE, 2);
-  gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, FALSE, 0);
-
-  frame = gtk_frame_new (NULL);
-  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
-  gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, FALSE, 0);
-  ld->histogram = gimp_histogram_view_new (HISTOGRAM_WIDTH, HISTOGRAM_HEIGHT);
-  gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (ld->histogram));
-
-  /* ignore button_events, since we don't want the user to be able to set the range */
-  gtk_widget_set_events (GTK_WIDGET (ld->histogram), 
-			 (GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK));
-
-  gtk_widget_show (GTK_WIDGET (ld->histogram));
-  gtk_widget_show (frame);
-  gtk_widget_show (hbox);
-
   /*  The input levels drawing area  */
   hbox = gtk_hbox_new (TRUE, 2);
   gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, FALSE, 0);
@@ -624,40 +624,79 @@
   gtk_widget_show (frame);
   gtk_widget_show (hbox);
 
-  gtk_widget_show (vbox);
+  /*  Horizontal button box for auto / reset this channel */
+  hbbox = gtk_hbutton_box_new ();
+  gtk_box_set_spacing (GTK_BOX (hbbox), 4);
+  gtk_button_box_set_layout (GTK_BUTTON_BOX (hbbox), GTK_BUTTONBOX_SPREAD);
+  gtk_box_pack_start (GTK_BOX (vbox), hbbox, FALSE, FALSE, 0);
 
-  /*  The preview toggle  */
-  hbox = gtk_hbox_new (FALSE, 4);
-  gtk_box_pack_end (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
+  button = gtk_button_new_with_label (_("Auto Channel"));
+  GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+  gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
 
-  toggle = gtk_check_button_new_with_label (_("Preview"));
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), ld->preview);
-  gtk_box_pack_end (GTK_BOX (hbox), toggle, FALSE, FALSE, 0);
+  g_signal_connect (G_OBJECT (button), "clicked",
+		      G_CALLBACK (levels_auto_callback),
+		      ld);
 
-  g_signal_connect (G_OBJECT (toggle), "toggled",
-                    G_CALLBACK (levels_preview_update),
-                    ld);
+  gtk_widget_show (button);
 
-  gtk_widget_show (toggle);
+  button = gtk_button_new_with_label (_("Reset Channel"));
+  GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+  gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
 
-  gtk_widget_show (hbox);
+  g_signal_connect (G_OBJECT (button), "clicked",
+		      G_CALLBACK (levels_reset_callback),
+		      ld);
 
-  /*  Horizontal button box for auto / load / save  */
-  hbbox = gtk_hbutton_box_new ();
+  gtk_widget_show (button);
+  gtk_widget_show (hbbox);
+
+  gtk_widget_show (vbox);
+  gtk_widget_show (tabbedarea); 
+ /* End the tabbed area here, when we have tabs */
+
+  /* Horizontal box to hold two vertical button boxes */
+  hbox = gtk_hbox_new (TRUE, 4);
+  //gtk_box_set_layout (GTK_BOX (hbox), GTK_BUTTONBOX_SPREAD);
+  gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
+
+  /*  Vertical button box for auto all / reset all  */
+  frame = gtk_frame_new(_("All Channels"));
+  hbbox = gtk_vbutton_box_new ();
   gtk_box_set_spacing (GTK_BOX (hbbox), 4);
   gtk_button_box_set_layout (GTK_BUTTON_BOX (hbbox), GTK_BUTTONBOX_SPREAD);
-  gtk_box_pack_end (GTK_BOX (main_vbox), hbbox, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
+  gtk_container_add (GTK_CONTAINER(frame), hbbox);
+  button = gtk_button_new_with_label (_("Auto All"));
+  GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+  gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
 
-  button = gtk_button_new_with_label (_("Auto"));
+  g_signal_connect (G_OBJECT (button), "clicked",
+                    G_CALLBACK (levels_auto_all_callback),
+                    ld);
+
+  gtk_widget_show (button);
+
+  button = gtk_button_new_with_label (_("Reset All"));
   GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
   gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
 
   g_signal_connect (G_OBJECT (button), "clicked",
-		      G_CALLBACK (levels_auto_callback),
-		      ld);
+                    G_CALLBACK (levels_reset_all_callback),
+                    ld);
 
   gtk_widget_show (button);
 
+  gtk_widget_show (hbbox);
+  gtk_widget_show (frame);
+
+  /*  Vertical button box for load / save  */
+  frame = gtk_frame_new("File");
+  hbbox = gtk_vbutton_box_new ();
+  gtk_box_set_spacing (GTK_BOX (hbbox), 4);
+  gtk_button_box_set_layout (GTK_BUTTON_BOX (hbbox), GTK_BUTTONBOX_SPREAD);
+  gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
+  gtk_container_add (GTK_CONTAINER(frame), hbbox);
   button = gtk_button_new_with_label (_("Load"));
   GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
   gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
@@ -679,6 +718,24 @@
   gtk_widget_show (button);
 
   gtk_widget_show (hbbox);
+  gtk_widget_show (frame);
+  gtk_widget_show (hbox);
+
+  /*  The preview toggle  */
+  hbox = gtk_hbox_new (FALSE, 4);
+  gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
+
+  toggle = gtk_check_button_new_with_label (_("Preview"));
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), ld->preview);
+  gtk_box_pack_end (GTK_BOX (hbox), toggle, FALSE, FALSE, 0);
+
+  g_signal_connect (G_OBJECT (toggle), "toggled",
+                    G_CALLBACK (levels_preview_update),
+                    ld);
+
+  gtk_widget_show (toggle);
+
+  gtk_widget_show (hbox);
 
   gtk_widget_show (main_vbox);
   gtk_widget_show (ld->shell);
@@ -1058,6 +1115,32 @@
 }
 
 static void
+reset_one_channel (LevelsDialog* ld, int channel)
+{
+  ld->low_input[channel]   = 0;
+  ld->gamma[channel]       = 1.0;
+  ld->high_input[channel]  = 255;
+  ld->low_output[channel]  = 0;
+  ld->high_output[channel] = 255;
+}
+
+static void
+levels_reset_all_callback (GtkWidget *widget,
+                           gpointer   data)
+{
+  int i;
+  LevelsDialog *ld = (LevelsDialog *) data;
+
+  for (i = 0; i < 5; i++)
+    reset_one_channel(ld, i);
+
+  levels_update (ld, ALL);
+  
+  if (ld->preview)
+    levels_preview (ld);
+}
+
+static void
 levels_reset_callback (GtkWidget *widget,
 		       gpointer   data)
 {
@@ -1065,11 +1148,7 @@
 
   ld = (LevelsDialog *) data;
 
-  ld->low_input[ld->channel]   = 0;
-  ld->gamma[ld->channel]       = 1.0;
-  ld->high_input[ld->channel]  = 255;
-  ld->low_output[ld->channel]  = 0;
-  ld->high_output[ld->channel] = 255;
+  reset_one_channel(ld, ld->channel);
 
   levels_update (ld, ALL);
   
@@ -1144,18 +1223,30 @@
 		      gpointer   data)
 {
   LevelsDialog *ld;
-  int channel;
 
   ld = (LevelsDialog *) data;
 
+  /*  Set the overall value to defaults  */
+  reset_one_channel (ld, GIMP_HISTOGRAM_VALUE);
+
+  levels_adjust_channel (ld, ld->hist, ld->channel);
+
+  levels_update (ld, ALL);
+  if (ld->preview)
+    levels_preview (ld);
+}
+
+static void
+levels_auto_all_callback (GtkWidget *widget,
+                          gpointer   data)
+{
+  LevelsDialog *ld = (LevelsDialog *) data;
+  int channel;
+
   if (ld->color)
     {
       /*  Set the overall value to defaults  */
-      ld->low_input[GIMP_HISTOGRAM_VALUE]   = 0;
-      ld->gamma[GIMP_HISTOGRAM_VALUE]       = 1.0;
-      ld->high_input[GIMP_HISTOGRAM_VALUE]  = 255;
-      ld->low_output[GIMP_HISTOGRAM_VALUE]  = 0;
-      ld->high_output[GIMP_HISTOGRAM_VALUE] = 255;
+      reset_one_channel(ld, GIMP_HISTOGRAM_VALUE);
 
       for (channel = 0; channel < 3; channel ++)
 	levels_adjust_channel (ld, ld->hist, channel + 1);
