gimp r24705 - in trunk: . app/tools



Author: mitch
Date: Fri Jan 25 10:02:11 2008
New Revision: 24705
URL: http://svn.gnome.org/viewvc/gimp?rev=24705&view=rev

Log:
2008-01-25  Michael Natterer  <mitch gimp org>

	* app/tools/gimpcurvestool.[ch]
	* app/tools/gimplevelstool.[ch]: remove the "channel" member from
	the tool struct and use the channel from the options object
	instead.



Modified:
   trunk/ChangeLog
   trunk/app/tools/gimpcurvestool.c
   trunk/app/tools/gimpcurvestool.h
   trunk/app/tools/gimplevelstool.c
   trunk/app/tools/gimplevelstool.h

Modified: trunk/app/tools/gimpcurvestool.c
==============================================================================
--- trunk/app/tools/gimpcurvestool.c	(original)
+++ trunk/app/tools/gimpcurvestool.c	Fri Jan 25 10:02:11 2008
@@ -179,8 +179,7 @@
   GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (tool);
   gint              i;
 
-  tool->lut     = gimp_lut_new ();
-  tool->channel = GIMP_HISTOGRAM_VALUE;
+  tool->lut = gimp_lut_new ();
 
   for (i = 0; i < G_N_ELEMENTS (tool->col_value); i++)
     tool->col_value[i] = -1;
@@ -236,9 +235,8 @@
   if (! c_tool->hist)
     c_tool->hist = gimp_histogram_new ();
 
-  c_tool->channel = c_tool->config->channel;
-  c_tool->color   = gimp_drawable_is_rgb (drawable);
-  c_tool->alpha   = gimp_drawable_has_alpha (drawable);
+  c_tool->color = gimp_drawable_is_rgb (drawable);
+  c_tool->alpha = gimp_drawable_has_alpha (drawable);
 
   GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
 
@@ -250,13 +248,13 @@
                                       curves_menu_sensitivity, c_tool, NULL);
 
   gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (c_tool->channel_menu),
-                                 c_tool->channel);
+                                 c_tool->config->channel);
 
   gimp_drawable_calculate_histogram (drawable, c_tool->hist);
   gimp_histogram_view_set_background (GIMP_HISTOGRAM_VIEW (c_tool->graph),
                                       c_tool->hist);
   gimp_curve_view_set_curve (GIMP_CURVE_VIEW (c_tool->graph),
-                             c_tool->config->curve[c_tool->channel]);
+                             c_tool->config->curve[c_tool->config->channel]);
 
   return TRUE;
 }
@@ -269,24 +267,25 @@
                                  GimpButtonReleaseType  release_type,
                                  GimpDisplay           *display)
 {
-  GimpCurvesTool *c_tool = GIMP_CURVES_TOOL (tool);
+  GimpCurvesTool   *c_tool = GIMP_CURVES_TOOL (tool);
+  GimpCurvesConfig *config = c_tool->config;
 
   if (state & GDK_SHIFT_MASK)
     {
-      GimpCurve *curve = c_tool->config->curve[c_tool->channel];
+      GimpCurve *curve = config->curve[config->channel];
       gint       closest;
 
       closest =
         gimp_curve_get_closest_point (curve,
-                                      c_tool->col_value[c_tool->channel]);
+                                      c_tool->col_value[config->channel]);
 
       gimp_curve_view_set_selected (GIMP_CURVE_VIEW (c_tool->graph),
                                     closest);
 
       gimp_curve_set_point (curve,
                             closest,
-                            c_tool->col_value[c_tool->channel],
-                            curve->curve[c_tool->col_value[c_tool->channel]]);
+                            c_tool->col_value[config->channel],
+                            curve->curve[c_tool->col_value[config->channel]]);
     }
   else if (state & GDK_CONTROL_MASK)
     {
@@ -294,7 +293,7 @@
 
       for (i = 0; i < 5; i++)
         {
-          GimpCurve *curve = c_tool->config->curve[i];
+          GimpCurve *curve = config->curve[i];
           gint       closest;
 
           closest =
@@ -386,7 +385,7 @@
   tool->col_value[GIMP_HISTOGRAM_VALUE] = MAX (MAX (r, g), b);
 
   gimp_curve_view_set_xpos (GIMP_CURVE_VIEW (tool->graph),
-                            tool->col_value[tool->channel]);
+                            tool->col_value[tool->config->channel]);
 }
 
 static GeglNode *
@@ -613,9 +612,13 @@
 static void
 gimp_curves_tool_reset (GimpImageMapTool *image_map_tool)
 {
-  GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool);
+  GimpCurvesTool       *tool    = GIMP_CURVES_TOOL (image_map_tool);
+  GimpHistogramChannel  channel = tool->config->channel;
 
   gimp_curves_config_reset (tool->config);
+  g_object_set (tool->config,
+                "channel", channel,
+                NULL);
 }
 
 static gboolean
@@ -719,29 +722,31 @@
 curves_curve_callback (GimpCurve      *curve,
                        GimpCurvesTool *tool)
 {
-  if (curve != tool->config->curve[tool->channel])
+  GimpCurvesConfig *config = tool->config;
+
+  if (curve != config->curve[config->channel])
     return;
 
   if (tool->xrange)
     {
-      switch (tool->channel)
+      switch (config->channel)
         {
         case GIMP_HISTOGRAM_VALUE:
         case GIMP_HISTOGRAM_ALPHA:
         case GIMP_HISTOGRAM_RGB:
           gimp_color_bar_set_buffers (GIMP_COLOR_BAR (tool->xrange),
-                                      tool->config->curve[tool->channel]->curve,
-                                      tool->config->curve[tool->channel]->curve,
-                                      tool->config->curve[tool->channel]->curve);
+                                      config->curve[config->channel]->curve,
+                                      config->curve[config->channel]->curve,
+                                      config->curve[config->channel]->curve);
           break;
 
         case GIMP_HISTOGRAM_RED:
         case GIMP_HISTOGRAM_GREEN:
         case GIMP_HISTOGRAM_BLUE:
           gimp_color_bar_set_buffers (GIMP_COLOR_BAR (tool->xrange),
-                                      tool->config->curve[GIMP_HISTOGRAM_RED]->curve,
-                                      tool->config->curve[GIMP_HISTOGRAM_GREEN]->curve,
-                                      tool->config->curve[GIMP_HISTOGRAM_BLUE]->curve);
+                                      config->curve[GIMP_HISTOGRAM_RED]->curve,
+                                      config->curve[GIMP_HISTOGRAM_GREEN]->curve,
+                                      config->curve[GIMP_HISTOGRAM_BLUE]->curve);
           break;
         }
     }
@@ -758,26 +763,27 @@
 
   if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value))
     {
-      tool->channel = value;
+      GimpCurvesConfig *config = tool->config;
 
-      g_object_set (tool->config,
-                    "channel", tool->channel,
+      g_object_set (config,
+                    "channel", value,
                     NULL);
 
       gimp_histogram_view_set_channel (GIMP_HISTOGRAM_VIEW (tool->graph),
-                                       tool->channel);
+                                       config->channel);
       gimp_curve_view_set_xpos (GIMP_CURVE_VIEW (tool->graph),
-                                tool->col_value[tool->channel]);
+                                tool->col_value[config->channel]);
 
-      gimp_color_bar_set_channel (GIMP_COLOR_BAR (tool->yrange), tool->channel);
+      gimp_color_bar_set_channel (GIMP_COLOR_BAR (tool->yrange),
+                                  config->channel);
 
       gimp_curve_view_set_curve (GIMP_CURVE_VIEW (tool->graph),
-                                 tool->config->curve[tool->channel]);
+                                 config->curve[config->channel]);
 
       gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (tool->curve_type),
-                                       tool->config->curve[tool->channel]->curve_type);
+                                       config->curve[config->channel]->curve_type);
 
-      curves_curve_callback (tool->config->curve[tool->channel], tool);
+      curves_curve_callback (config->curve[config->channel], tool);
     }
 }
 
@@ -785,7 +791,7 @@
 curves_channel_reset_callback (GtkWidget      *widget,
                                GimpCurvesTool *tool)
 {
-  gimp_curves_config_reset_channel (tool->config, tool->channel);
+  gimp_curves_config_reset_channel (tool->config, tool->config->channel);
 }
 
 static gboolean
@@ -819,12 +825,13 @@
 curves_curve_type_callback (GtkWidget      *widget,
                             GimpCurvesTool *tool)
 {
-  GimpCurveType curve_type;
+  GimpCurvesConfig *config = tool->config;
+  GimpCurveType     curve_type;
 
   gimp_radio_button_update (widget, &curve_type);
 
-  if (tool->config->curve[tool->channel]->curve_type != curve_type)
+  if (config->curve[config->channel]->curve_type != curve_type)
     {
-      gimp_curve_set_curve_type (tool->config->curve[tool->channel], curve_type);
+      gimp_curve_set_curve_type (config->curve[config->channel], curve_type);
     }
 }

Modified: trunk/app/tools/gimpcurvestool.h
==============================================================================
--- trunk/app/tools/gimpcurvestool.h	(original)
+++ trunk/app/tools/gimpcurvestool.h	Fri Jan 25 10:02:11 2008
@@ -43,7 +43,6 @@
   /* dialog */
   gboolean              color;
   gboolean              alpha;
-  GimpHistogramChannel  channel;
 
   gint                  col_value[5];
 

Modified: trunk/app/tools/gimplevelstool.c
==============================================================================
--- trunk/app/tools/gimplevelstool.c	(original)
+++ trunk/app/tools/gimplevelstool.c	Fri Jan 25 10:02:11 2008
@@ -182,7 +182,6 @@
 
   tool->lut           = gimp_lut_new ();
   tool->hist          = NULL;
-  tool->channel       = GIMP_HISTOGRAM_VALUE;
   tool->active_picker = NULL;
 
   im_tool->apply_func = (GimpImageMapApplyFunc) gimp_lut_process;
@@ -234,9 +233,8 @@
 
   gimp_levels_config_reset (l_tool->config);
 
-  l_tool->channel = l_tool->config->channel;
-  l_tool->color   = gimp_drawable_is_rgb (drawable);
-  l_tool->alpha   = gimp_drawable_has_alpha (drawable);
+  l_tool->color = gimp_drawable_is_rgb (drawable);
+  l_tool->alpha = gimp_drawable_has_alpha (drawable);
 
   if (l_tool->active_picker)
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (l_tool->active_picker),
@@ -248,7 +246,7 @@
                                       levels_menu_sensitivity, l_tool, NULL);
 
   gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (l_tool->channel_menu),
-                                 l_tool->channel);
+                                 l_tool->config->channel);
 
   levels_update_adjustments (l_tool);
 
@@ -689,9 +687,14 @@
 static void
 gimp_levels_tool_reset (GimpImageMapTool *image_map_tool)
 {
-  GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool);
+  GimpLevelsTool       *tool    = GIMP_LEVELS_TOOL (image_map_tool);
+  GimpHistogramChannel  channel = tool->config->channel;
 
   gimp_levels_config_reset (tool->config);
+  g_object_set (tool->config,
+                "channel", channel,
+                NULL);
+
   levels_update_adjustments (tool);
 }
 
@@ -700,16 +703,17 @@
                                 gpointer           fp,
                                 GError           **error)
 {
-  GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool);
-  FILE           *file = fp;
-  gint            low_input[5];
-  gint            high_input[5];
-  gint            low_output[5];
-  gint            high_output[5];
-  gdouble         gamma[5];
-  gint            i, fields;
-  gchar           buf[50];
-  gchar          *nptr;
+  GimpLevelsTool       *tool = GIMP_LEVELS_TOOL (image_map_tool);
+  FILE                 *file = fp;
+  GimpHistogramChannel  channel;
+  gint                  low_input[5];
+  gint                  high_input[5];
+  gint                  low_output[5];
+  gint                  high_output[5];
+  gdouble               gamma[5];
+  gint                  i, fields;
+  gchar                 buf[50];
+  gchar                *nptr;
 
   if (! fgets (buf, sizeof (buf), file) ||
       strcmp (buf, "# GIMP Levels File\n") != 0)
@@ -739,6 +743,8 @@
         goto error;
     }
 
+  channel = tool->config->channel;
+
   for (i = 0; i < 5; i++)
     {
       g_object_set (tool->config,
@@ -755,7 +761,7 @@
     }
 
   g_object_set (tool->config,
-                "channel", tool->channel,
+                "channel", channel,
                 NULL);
 
   levels_update_adjustments (tool);
@@ -797,17 +803,19 @@
 static void
 levels_update_adjustments (GimpLevelsTool *tool)
 {
+  GimpLevelsConfig *config = tool->config;
+
   tool->low_input->upper    = 255;
   tool->high_input->lower   = 0;
   tool->gamma_linear->lower = 0;
   tool->gamma_linear->upper = 255;
 
   gtk_adjustment_set_value (tool->low_input,
-                            tool->config->low_input[tool->channel] * 255.0);
+                            config->low_input[config->channel]  * 255.0);
   gtk_adjustment_set_value (tool->gamma,
-                            tool->config->gamma[tool->channel]);
+                            config->gamma[config->channel]);
   gtk_adjustment_set_value (tool->high_input,
-                            tool->config->high_input[tool->channel] * 255.0);
+                            config->high_input[config->channel] * 255.0);
 
   tool->low_input->upper    = tool->high_input->value;
   tool->high_input->lower   = tool->low_input->value;
@@ -818,9 +826,9 @@
   gtk_adjustment_changed (tool->gamma_linear);
 
   gtk_adjustment_set_value (tool->low_output,
-                            tool->config->low_output[tool->channel] * 255.0);
+                            config->low_output[config->channel]  * 255.0);
   gtk_adjustment_set_value (tool->high_output,
-                            tool->config->high_output[tool->channel] * 255.0);
+                            config->high_output[config->channel] * 255.0);
 
   levels_update_input_bar (tool);
 }
@@ -828,7 +836,9 @@
 static void
 levels_update_input_bar (GimpLevelsTool *tool)
 {
-  switch (tool->channel)
+  GimpLevelsConfig *config = tool->config;
+
+  switch (config->channel)
     {
     case GIMP_HISTOGRAM_VALUE:
     case GIMP_HISTOGRAM_ALPHA:
@@ -839,8 +849,8 @@
 
         for (i = 0; i < 256; i++)
           {
-            v[i] = gimp_operation_levels_map_input (tool->config,
-                                                    tool->channel,
+            v[i] = gimp_operation_levels_map_input (config,
+                                                    config->channel,
                                                     i / 255.0) * 255.999;
           }
 
@@ -860,13 +870,13 @@
 
         for (i = 0; i < 256; i++)
           {
-            r[i] = gimp_operation_levels_map_input (tool->config,
+            r[i] = gimp_operation_levels_map_input (config,
                                                     GIMP_HISTOGRAM_RED,
                                                     i / 255.0) * 255.999;
-            g[i] = gimp_operation_levels_map_input (tool->config,
+            g[i] = gimp_operation_levels_map_input (config,
                                                     GIMP_HISTOGRAM_GREEN,
                                                     i / 255.0) * 255.999;
-            b[i] = gimp_operation_levels_map_input (tool->config,
+            b[i] = gimp_operation_levels_map_input (config,
                                                     GIMP_HISTOGRAM_BLUE,
                                                     i / 255.0) * 255.999;
           }
@@ -886,16 +896,14 @@
 
   if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value))
     {
-      tool->channel = value;
-
       g_object_set (tool->config,
-                    "channel", tool->channel,
+                    "channel", value,
                     NULL);
 
       gimp_histogram_view_set_channel (GIMP_HISTOGRAM_VIEW (tool->hist_view),
-                                       tool->channel);
+                                       tool->config->channel);
       gimp_color_bar_set_channel (GIMP_COLOR_BAR (tool->output_bar),
-                                  tool->channel);
+                                  tool->config->channel);
 
       levels_update_adjustments (tool);
     }
@@ -905,7 +913,7 @@
 levels_channel_reset_callback (GtkWidget      *widget,
                                GimpLevelsTool *tool)
 {
-  gimp_levels_config_reset_channel (tool->config, tool->channel);
+  gimp_levels_config_reset_channel (tool->config, tool->config->channel);
   levels_update_adjustments (tool);
 
   gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
@@ -955,7 +963,7 @@
 
   delta = (tool->high_input->value - tool->low_input->value) / 2.0;
   mid   = tool->low_input->value + delta;
-  tmp   = log10 (1.0 / tool->config->gamma[tool->channel]);
+  tmp   = log10 (1.0 / tool->config->gamma[tool->config->channel]);
   value = mid + delta * tmp;
 
   gtk_adjustment_set_value (tool->gamma_linear, value);
@@ -986,16 +994,17 @@
 levels_low_input_changed (GtkAdjustment  *adjustment,
                           GimpLevelsTool *tool)
 {
-  gint value = ROUND (adjustment->value);
+  GimpLevelsConfig *config = tool->config;
+  gint              value  = ROUND (adjustment->value);
 
   tool->high_input->lower   = value;
   tool->gamma_linear->lower = value;
   gtk_adjustment_changed (tool->high_input);
   gtk_adjustment_changed (tool->gamma_linear);
 
-  if (tool->config->low_input[tool->channel] != value / 255.0)
+  if (config->low_input[config->channel] != value / 255.0)
     {
-      g_object_set (tool->config,
+      g_object_set (config,
                     "low-input", value / 255.0,
                     NULL);
       levels_update_input_bar (tool);
@@ -1010,9 +1019,11 @@
 levels_gamma_changed (GtkAdjustment  *adjustment,
                       GimpLevelsTool *tool)
 {
-  if (tool->config->gamma[tool->channel] != adjustment->value)
+  GimpLevelsConfig *config = tool->config;
+
+  if (config->gamma[config->channel] != adjustment->value)
     {
-      g_object_set (tool->config,
+      g_object_set (config,
                     "gamma", adjustment->value,
                     NULL);
       levels_update_input_bar (tool);
@@ -1027,16 +1038,17 @@
 levels_high_input_changed (GtkAdjustment  *adjustment,
                            GimpLevelsTool *tool)
 {
-  gint value = ROUND (adjustment->value);
+  GimpLevelsConfig *config = tool->config;
+  gint              value  = ROUND (adjustment->value);
 
   tool->low_input->upper    = value;
   tool->gamma_linear->upper = value;
   gtk_adjustment_changed (tool->low_input);
   gtk_adjustment_changed (tool->gamma_linear);
 
-  if (tool->config->high_input[tool->channel] != value / 255.0)
+  if (config->high_input[config->channel] != value / 255.0)
     {
-      g_object_set (tool->config,
+      g_object_set (config,
                     "high-input", value / 255.0,
                     NULL);
       levels_update_input_bar (tool);
@@ -1051,11 +1063,12 @@
 levels_low_output_changed (GtkAdjustment  *adjustment,
                            GimpLevelsTool *tool)
 {
-  gint value = ROUND (adjustment->value);
+  GimpLevelsConfig *config = tool->config;
+  gint              value  = ROUND (adjustment->value);
 
-  if (tool->config->low_output[tool->channel] != value / 255.0)
+  if (config->low_output[config->channel] != value / 255.0)
     {
-      g_object_set (tool->config,
+      g_object_set (config,
                     "low-output", value / 255.0,
                     NULL);
 
@@ -1067,11 +1080,12 @@
 levels_high_output_changed (GtkAdjustment  *adjustment,
                             GimpLevelsTool *tool)
 {
-  gint value = ROUND (adjustment->value);
+  GimpLevelsConfig *config = tool->config;
+  gint              value  = ROUND (adjustment->value);
 
-  if (tool->config->high_output[tool->channel] != value / 255.0)
+  if (config->high_output[config->channel] != value / 255.0)
     {
-      g_object_set (tool->config,
+      g_object_set (config,
                     "high-output", value / 255.0,
                     NULL);
 
@@ -1171,7 +1185,7 @@
   else
     {
       levels_input_adjust_by_color (tool->config,
-                                    value, tool->channel, color);
+                                    value, tool->config->channel, color);
     }
 
   levels_update_adjustments (tool);

Modified: trunk/app/tools/gimplevelstool.h
==============================================================================
--- trunk/app/tools/gimplevelstool.h	(original)
+++ trunk/app/tools/gimplevelstool.h	Fri Jan 25 10:02:11 2008
@@ -44,7 +44,6 @@
   /* dialog */
   gboolean              color;
   gboolean              alpha;
-  GimpHistogramChannel  channel;
 
   GimpHistogram        *hist;
 



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