[gimp/goat-invasion: 295/418] app: port gimp_image_pick_color() to return a Babl format
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion: 295/418] app: port gimp_image_pick_color() to return a Babl format
- Date: Wed, 4 Apr 2012 10:50:35 +0000 (UTC)
commit b68efd6e065d80466dec1cfd8d3a8b7bc0092f74
Author: Michael Natterer <mitch gimp org>
Date: Wed Mar 28 21:37:59 2012 +0200
app: port gimp_image_pick_color() to return a Babl format
instead of a GimpImageType.
app/core/gimpimage-pick-color.c | 6 +-
app/core/gimpimage-pick-color.h | 2 +-
app/core/gimpmarshal.list | 2 +-
app/display/gimpcursorview.c | 8 ++--
app/tools/gimpairbrushtool.c | 1 +
app/tools/gimpcolorpickertool.c | 16 ++++----
app/tools/gimpcolortool.c | 30 +++++++-------
app/tools/gimpcolortool.h | 4 +-
app/tools/gimpconvolvetool.c | 1 +
app/tools/gimpcurvestool.c | 4 +-
app/tools/gimpdodgeburntool.c | 1 +
app/tools/gimperasertool.c | 1 +
app/tools/gimphealtool.c | 1 +
app/tools/gimpinktool.c | 1 +
app/tools/gimplevelstool.c | 8 ++-
app/tools/gimppaintbrushtool.c | 1 +
app/tools/gimppenciltool.c | 1 +
app/tools/gimpsmudgetool.c | 1 +
app/widgets/gimpcolorframe.c | 77 +++++++++++++++++------------------
app/widgets/gimpcolorframe.h | 4 +-
app/widgets/gimpsamplepointeditor.c | 6 +-
21 files changed, 93 insertions(+), 83 deletions(-)
---
diff --git a/app/core/gimpimage-pick-color.c b/app/core/gimpimage-pick-color.c
index 963f784..818bbe7 100644
--- a/app/core/gimpimage-pick-color.c
+++ b/app/core/gimpimage-pick-color.c
@@ -35,7 +35,7 @@ gimp_image_pick_color (GimpImage *image,
gboolean sample_merged,
gboolean sample_average,
gdouble average_radius,
- GimpImageType *sample_type,
+ const Babl **sample_format,
GimpRGB *color,
gint *color_index)
{
@@ -76,8 +76,8 @@ gimp_image_pick_color (GimpImage *image,
* Instead, call gimp_pickable_flush() in the callers if needed.
*/
- if (sample_type)
- *sample_type = gimp_pickable_get_image_type (pickable);
+ if (sample_format)
+ *sample_format = gimp_pickable_get_format (pickable);
return gimp_pickable_pick_color (pickable, x, y,
sample_average, average_radius,
diff --git a/app/core/gimpimage-pick-color.h b/app/core/gimpimage-pick-color.h
index b115a50..914c92f 100644
--- a/app/core/gimpimage-pick-color.h
+++ b/app/core/gimpimage-pick-color.h
@@ -26,7 +26,7 @@ gboolean gimp_image_pick_color (GimpImage *image,
gboolean sample_merged,
gboolean sample_average,
gdouble average_radius,
- GimpImageType *sample_type,
+ const Babl **sample_format,
GimpRGB *color,
gint *color_index);
diff --git a/app/core/gimpmarshal.list b/app/core/gimpmarshal.list
index e2453d2..faea253 100644
--- a/app/core/gimpmarshal.list
+++ b/app/core/gimpmarshal.list
@@ -37,7 +37,7 @@ VOID: DOUBLE
VOID: DOUBLE, DOUBLE
VOID: DOUBLE, DOUBLE, DOUBLE, DOUBLE
VOID: ENUM
-VOID: ENUM, ENUM, BOXED, INT
+VOID: ENUM, POINTER, BOXED, INT
VOID: ENUM, INT
VOID: ENUM, INT, BOOLEAN
VOID: ENUM, OBJECT
diff --git a/app/display/gimpcursorview.c b/app/display/gimpcursorview.c
index 7218b92..832b5b4 100644
--- a/app/display/gimpcursorview.c
+++ b/app/display/gimpcursorview.c
@@ -725,7 +725,7 @@ gimp_cursor_view_update_cursor (GimpCursorView *view,
GimpUnit unit = shell_unit;
gboolean in_image;
gchar buf[32];
- GimpImageType sample_type;
+ const Babl *sample_format;
GimpRGB color;
gint color_index;
gdouble xres;
@@ -763,12 +763,12 @@ gimp_cursor_view_update_cursor (GimpCursorView *view,
(gint) floor (y),
view->priv->sample_merged,
FALSE, 0.0,
- &sample_type, &color, &color_index))
+ &sample_format, &color, &color_index))
{
gimp_color_frame_set_color (GIMP_COLOR_FRAME (view->priv->color_frame_1),
- sample_type, &color, color_index);
+ sample_format, &color, color_index);
gimp_color_frame_set_color (GIMP_COLOR_FRAME (view->priv->color_frame_2),
- sample_type, &color, color_index);
+ sample_format, &color, color_index);
}
else
{
diff --git a/app/tools/gimpairbrushtool.c b/app/tools/gimpairbrushtool.c
index 2dc2e72..85a67a9 100644
--- a/app/tools/gimpairbrushtool.c
+++ b/app/tools/gimpairbrushtool.c
@@ -17,6 +17,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
diff --git a/app/tools/gimpcolorpickertool.c b/app/tools/gimpcolorpickertool.c
index f20237e..f1a396c 100644
--- a/app/tools/gimpcolorpickertool.c
+++ b/app/tools/gimpcolorpickertool.c
@@ -61,7 +61,7 @@ static void gimp_color_picker_tool_oper_update (GimpTool *tool,
static void gimp_color_picker_tool_picked (GimpColorTool *color_tool,
GimpColorPickState pick_state,
- GimpImageType sample_type,
+ const Babl *sample_format,
const GimpRGB *color,
gint color_index);
@@ -70,7 +70,7 @@ static void gimp_color_picker_tool_info_response (GtkWidget *widget,
gint response_id,
GimpColorPickerTool *picker_tool);
static void gimp_color_picker_tool_info_update (GimpColorPickerTool *picker_tool,
- GimpImageType sample_type,
+ const Babl *sample_format,
const GimpRGB *color,
gint color_index);
@@ -272,7 +272,7 @@ gimp_color_picker_tool_oper_update (GimpTool *tool,
static void
gimp_color_picker_tool_picked (GimpColorTool *color_tool,
GimpColorPickState pick_state,
- GimpImageType sample_type,
+ const Babl *sample_format,
const GimpRGB *color,
gint color_index)
{
@@ -285,11 +285,11 @@ gimp_color_picker_tool_picked (GimpColorTool *color_tool,
gimp_color_picker_tool_info_create (picker_tool);
if (picker_tool->dialog)
- gimp_color_picker_tool_info_update (picker_tool, sample_type,
+ gimp_color_picker_tool_info_update (picker_tool, sample_format,
color, color_index);
GIMP_COLOR_TOOL_CLASS (parent_class)->picked (color_tool, pick_state,
- sample_type, color,
+ sample_format, color,
color_index);
}
@@ -374,7 +374,7 @@ gimp_color_picker_tool_info_response (GtkWidget *widget,
static void
gimp_color_picker_tool_info_update (GimpColorPickerTool *picker_tool,
- GimpImageType sample_type,
+ const Babl *sample_format,
const GimpRGB *color,
gint color_index)
{
@@ -390,9 +390,9 @@ gimp_color_picker_tool_info_update (GimpColorPickerTool *picker_tool,
color);
gimp_color_frame_set_color (GIMP_COLOR_FRAME (picker_tool->color_frame1),
- sample_type, color, color_index);
+ sample_format, color, color_index);
gimp_color_frame_set_color (GIMP_COLOR_FRAME (picker_tool->color_frame2),
- sample_type, color, color_index);
+ sample_format, color, color_index);
/* don't use gtk_window_present() because it would focus the dialog */
if (gtk_widget_get_visible (picker_tool->dialog))
diff --git a/app/tools/gimpcolortool.c b/app/tools/gimpcolortool.c
index 1e0d0eb..e00aab5 100644
--- a/app/tools/gimpcolortool.c
+++ b/app/tools/gimpcolortool.c
@@ -104,7 +104,7 @@ static void gimp_color_tool_draw (GimpDrawTool *draw_tool);
static gboolean gimp_color_tool_real_pick (GimpColorTool *color_tool,
gint x,
gint y,
- GimpImageType *sample_type,
+ const Babl **sample_format,
GimpRGB *color,
gint *color_index);
static void gimp_color_tool_pick (GimpColorTool *tool,
@@ -113,7 +113,7 @@ static void gimp_color_tool_pick (GimpColorTool *tool,
gint y);
static void gimp_color_tool_real_picked (GimpColorTool *color_tool,
GimpColorPickState pick_state,
- GimpImageType sample_type,
+ const Babl *sample_format,
const GimpRGB *color,
gint color_index);
@@ -138,7 +138,7 @@ gimp_color_tool_class_init (GimpColorToolClass *klass)
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpColorToolClass, picked),
NULL, NULL,
- gimp_marshal_VOID__ENUM_ENUM_BOXED_INT,
+ gimp_marshal_VOID__ENUM_POINTER_BOXED_INT,
G_TYPE_NONE, 4,
GIMP_TYPE_COLOR_PICK_STATE,
GIMP_TYPE_IMAGE_TYPE,
@@ -570,12 +570,12 @@ gimp_color_tool_draw (GimpDrawTool *draw_tool)
}
static gboolean
-gimp_color_tool_real_pick (GimpColorTool *color_tool,
- gint x,
- gint y,
- GimpImageType *sample_type,
- GimpRGB *color,
- gint *color_index)
+gimp_color_tool_real_pick (GimpColorTool *color_tool,
+ gint x,
+ gint y,
+ const Babl **sample_format,
+ GimpRGB *color,
+ gint *color_index)
{
GimpTool *tool = GIMP_TOOL (color_tool);
GimpImage *image = gimp_display_get_image (tool->display);
@@ -587,7 +587,7 @@ gimp_color_tool_real_pick (GimpColorTool *color_tool,
color_tool->options->sample_merged,
color_tool->options->sample_average,
color_tool->options->average_radius,
- sample_type,
+ sample_format,
color,
color_index);
}
@@ -595,7 +595,7 @@ gimp_color_tool_real_pick (GimpColorTool *color_tool,
static void
gimp_color_tool_real_picked (GimpColorTool *color_tool,
GimpColorPickState pick_state,
- GimpImageType sample_type,
+ const Babl *sample_format,
const GimpRGB *color,
gint color_index)
{
@@ -610,7 +610,7 @@ gimp_color_tool_real_picked (GimpColorTool *color_tool,
{
GtkWidget *widget;
- if (GIMP_IMAGE_TYPE_IS_INDEXED (sample_type))
+ if (babl_format_is_palette (sample_format))
{
widget = gimp_dialog_factory_find_widget (gimp_dialog_factory_get_singleton (),
"gimp-indexed-palette");
@@ -704,17 +704,17 @@ gimp_color_tool_pick (GimpColorTool *tool,
gint y)
{
GimpColorToolClass *klass;
- GimpImageType sample_type;
+ const Babl *sample_format;
GimpRGB color;
gint color_index;
klass = GIMP_COLOR_TOOL_GET_CLASS (tool);
if (klass->pick &&
- klass->pick (tool, x, y, &sample_type, &color, &color_index))
+ klass->pick (tool, x, y, &sample_format, &color, &color_index))
{
g_signal_emit (tool, gimp_color_tool_signals[PICKED], 0,
- pick_state, sample_type, &color, color_index);
+ pick_state, sample_format, &color, color_index);
}
}
diff --git a/app/tools/gimpcolortool.h b/app/tools/gimpcolortool.h
index e2e278d..7599ddd 100644
--- a/app/tools/gimpcolortool.h
+++ b/app/tools/gimpcolortool.h
@@ -59,14 +59,14 @@ struct _GimpColorToolClass
gboolean (* pick) (GimpColorTool *tool,
gint x,
gint y,
- GimpImageType *sample_type,
+ const Babl **sample_format,
GimpRGB *color,
gint *color_index);
/* signals */
void (* picked) (GimpColorTool *tool,
GimpColorPickState pick_state,
- GimpImageType sample_type,
+ const Babl *sample_format,
const GimpRGB *color,
gint color_index);
};
diff --git a/app/tools/gimpconvolvetool.c b/app/tools/gimpconvolvetool.c
index 471e373..b2f46d2 100644
--- a/app/tools/gimpconvolvetool.c
+++ b/app/tools/gimpconvolvetool.c
@@ -17,6 +17,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
diff --git a/app/tools/gimpcurvestool.c b/app/tools/gimpcurvestool.c
index 8e056cb..3e52b55 100644
--- a/app/tools/gimpcurvestool.c
+++ b/app/tools/gimpcurvestool.c
@@ -82,7 +82,7 @@ static void gimp_curves_tool_oper_update (GimpTool *tool,
static void gimp_curves_tool_color_picked (GimpColorTool *color_tool,
GimpColorPickState pick_state,
- GimpImageType sample_type,
+ const Babl *sample_format,
const GimpRGB *color,
gint color_index);
static GeglNode * gimp_curves_tool_get_operation (GimpImageMapTool *image_map_tool,
@@ -326,7 +326,7 @@ gimp_curves_tool_oper_update (GimpTool *tool,
static void
gimp_curves_tool_color_picked (GimpColorTool *color_tool,
GimpColorPickState pick_state,
- GimpImageType sample_type,
+ const Babl *sample_format,
const GimpRGB *color,
gint color_index)
{
diff --git a/app/tools/gimpdodgeburntool.c b/app/tools/gimpdodgeburntool.c
index 1f140de..7adaced 100644
--- a/app/tools/gimpdodgeburntool.c
+++ b/app/tools/gimpdodgeburntool.c
@@ -17,6 +17,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
diff --git a/app/tools/gimperasertool.c b/app/tools/gimperasertool.c
index 44474b3..e73c4a8 100644
--- a/app/tools/gimperasertool.c
+++ b/app/tools/gimperasertool.c
@@ -17,6 +17,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
diff --git a/app/tools/gimphealtool.c b/app/tools/gimphealtool.c
index f40bb7f..be13b7f 100644
--- a/app/tools/gimphealtool.c
+++ b/app/tools/gimphealtool.c
@@ -17,6 +17,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
diff --git a/app/tools/gimpinktool.c b/app/tools/gimpinktool.c
index 66316da..49c5b1f 100644
--- a/app/tools/gimpinktool.c
+++ b/app/tools/gimpinktool.c
@@ -17,6 +17,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
diff --git a/app/tools/gimplevelstool.c b/app/tools/gimplevelstool.c
index 51c4c70..26aebb7 100644
--- a/app/tools/gimplevelstool.c
+++ b/app/tools/gimplevelstool.c
@@ -73,7 +73,7 @@ static gboolean gimp_levels_tool_initialize (GimpTool *tool,
static void gimp_levels_tool_color_picked (GimpColorTool *color_tool,
GimpColorPickState pick_state,
- GimpImageType sample_type,
+ const Babl *sample_format,
const GimpRGB *color,
gint color_index);
@@ -1159,7 +1159,7 @@ levels_input_adjust_by_color (GimpLevelsConfig *config,
static void
gimp_levels_tool_color_picked (GimpColorTool *color_tool,
GimpColorPickState pick_state,
- GimpImageType sample_type,
+ const Babl *sample_format,
const GimpRGB *color,
gint color_index)
{
@@ -1169,7 +1169,9 @@ gimp_levels_tool_color_picked (GimpColorTool *color_tool,
value = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (tool->active_picker),
"pick-value"));
- if (value & PICK_ALL_CHANNELS && GIMP_IMAGE_TYPE_IS_RGB (sample_type))
+ if (value & PICK_ALL_CHANNELS &&
+ (sample_format == babl_format ("R'G'B' u8") ||
+ sample_format == babl_format ("R'G'B'A u8")))
{
GimpHistogramChannel channel;
diff --git a/app/tools/gimppaintbrushtool.c b/app/tools/gimppaintbrushtool.c
index 7f07463..32c5623 100644
--- a/app/tools/gimppaintbrushtool.c
+++ b/app/tools/gimppaintbrushtool.c
@@ -17,6 +17,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
diff --git a/app/tools/gimppenciltool.c b/app/tools/gimppenciltool.c
index 42e7b49..fa038c2 100644
--- a/app/tools/gimppenciltool.c
+++ b/app/tools/gimppenciltool.c
@@ -17,6 +17,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
diff --git a/app/tools/gimpsmudgetool.c b/app/tools/gimpsmudgetool.c
index 17512bd..7b2fcba 100644
--- a/app/tools/gimpsmudgetool.c
+++ b/app/tools/gimpsmudgetool.c
@@ -17,6 +17,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
diff --git a/app/widgets/gimpcolorframe.c b/app/widgets/gimpcolorframe.c
index 093ae28..68da1a5 100644
--- a/app/widgets/gimpcolorframe.c
+++ b/app/widgets/gimpcolorframe.c
@@ -116,8 +116,8 @@ gimp_color_frame_init (GimpColorFrame *frame)
GtkWidget *vbox2;
gint i;
- frame->sample_valid = FALSE;
- frame->sample_type = GIMP_RGB_IMAGE;
+ frame->sample_valid = FALSE;
+ frame->sample_format = babl_format ("R'G'B' u8");
gimp_rgba_set (&frame->color, 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE);
@@ -407,38 +407,37 @@ gimp_color_frame_set_has_color_area (GimpColorFrame *frame,
/**
* gimp_color_frame_set_color:
- * @frame: The #GimpColorFrame.
- * @sample_type: The type of the #GimpDrawable or #GimpImage the @color
- * was picked from.
- * @color: The @color to set.
- * @color_index: The @color's index. This value is ignored unless
- * @sample_type equals to #GIMP_INDEXED_IMAGE or
- * #GIMP_INDEXEDA_IMAGE.
+ * @frame: The #GimpColorFrame.
+ * @sample_format: The format of the #GimpDrawable or #GimpImage the @color
+ * was picked from.
+ * @color: The @color to set.
+ * @color_index: The @color's index. This value is ignored unless
+ * @sample_format is an indexed format.
*
* Sets the color sample to display in the #GimpColorFrame.
**/
void
gimp_color_frame_set_color (GimpColorFrame *frame,
- GimpImageType sample_type,
+ const Babl *sample_format,
const GimpRGB *color,
gint color_index)
{
g_return_if_fail (GIMP_IS_COLOR_FRAME (frame));
g_return_if_fail (color != NULL);
- if (frame->sample_valid &&
- frame->sample_type == sample_type &&
- frame->color_index == color_index &&
+ if (frame->sample_valid &&
+ frame->sample_format == sample_format &&
+ frame->color_index == color_index &&
gimp_rgba_distance (&frame->color, color) < 0.0001)
{
frame->color = *color;
return;
}
- frame->sample_valid = TRUE;
- frame->sample_type = sample_type;
- frame->color = *color;
- frame->color_index = color_index;
+ frame->sample_valid = TRUE;
+ frame->sample_format = sample_format;
+ frame->color = *color;
+ frame->color_index = color_index;
gimp_color_frame_update (frame);
}
@@ -492,7 +491,7 @@ gimp_color_frame_update (GimpColorFrame *frame)
guchar r, g, b, a;
gint i;
- has_alpha = GIMP_IMAGE_TYPE_HAS_ALPHA (frame->sample_type);
+ has_alpha = babl_format_has_alpha (frame->sample_format);
if (frame->sample_valid)
{
@@ -505,22 +504,18 @@ gimp_color_frame_update (GimpColorFrame *frame)
switch (frame->frame_mode)
{
case GIMP_COLOR_FRAME_MODE_PIXEL:
- switch (GIMP_IMAGE_TYPE_BASE_TYPE (frame->sample_type))
+ if (frame->sample_format == babl_format ("Y' u8") ||
+ frame->sample_format == babl_format ("Y'A u8"))
{
- case GIMP_INDEXED:
- names[4] = _("Index:");
+ names[0] = _("Value:");
if (frame->sample_valid)
- {
- /* color_index will be -1 for an averaged sample */
- if (frame->color_index < 0)
- names[4] = NULL;
- else
- values[4] = g_strdup_printf ("%d", frame->color_index);
- }
- /* fallthrough */
+ values[0] = g_strdup_printf ("%d", r);
- case GIMP_RGB:
+ alpha_row = 1;
+ }
+ else
+ {
names[0] = _("Red:");
names[1] = _("Green:");
names[2] = _("Blue:");
@@ -533,16 +528,20 @@ gimp_color_frame_update (GimpColorFrame *frame)
}
alpha_row = 3;
- break;
- case GIMP_GRAY:
- names[0] = _("Value:");
-
- if (frame->sample_valid)
- values[0] = g_strdup_printf ("%d", r);
-
- alpha_row = 1;
- break;
+ if (babl_format_is_palette (frame->sample_format))
+ {
+ names[4] = _("Index:");
+
+ if (frame->sample_valid)
+ {
+ /* color_index will be -1 for an averaged sample */
+ if (frame->color_index < 0)
+ names[4] = NULL;
+ else
+ values[4] = g_strdup_printf ("%d", frame->color_index);
+ }
+ }
}
break;
diff --git a/app/widgets/gimpcolorframe.h b/app/widgets/gimpcolorframe.h
index 7b5e6a6..d77d2fd 100644
--- a/app/widgets/gimpcolorframe.h
+++ b/app/widgets/gimpcolorframe.h
@@ -37,7 +37,7 @@ struct _GimpColorFrame
GimpFrame parent_instance;
gboolean sample_valid;
- GimpImageType sample_type;
+ const Babl *sample_format;
GimpRGB color;
gint color_index;
@@ -78,7 +78,7 @@ void gimp_color_frame_set_has_color_area (GimpColorFrame *frame,
gboolean has_color_area);
void gimp_color_frame_set_color (GimpColorFrame *frame,
- GimpImageType sample_type,
+ const Babl *format,
const GimpRGB *color,
gint color_index);
void gimp_color_frame_set_invalid (GimpColorFrame *frame);
diff --git a/app/widgets/gimpsamplepointeditor.c b/app/widgets/gimpsamplepointeditor.c
index 54069de..56f3fbc 100644
--- a/app/widgets/gimpsamplepointeditor.c
+++ b/app/widgets/gimpsamplepointeditor.c
@@ -467,7 +467,7 @@ gimp_sample_point_editor_update (GimpSamplePointEditor *editor)
{
GimpSamplePoint *sample_point = list->data;
GimpColorFrame *color_frame;
- GimpImageType image_type;
+ const Babl *format;
GimpRGB color;
gint color_index;
@@ -480,11 +480,11 @@ gimp_sample_point_editor_update (GimpSamplePointEditor *editor)
sample_point->y,
editor->sample_merged,
FALSE, 0.0,
- &image_type,
+ &format,
&color,
&color_index))
{
- gimp_color_frame_set_color (color_frame, image_type,
+ gimp_color_frame_set_color (color_frame, format,
&color, color_index);
}
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]