remove enum GimpColorPickMode...

2007-02-07  Michael Natterer  <mitch@gimp.org>

	* app/tools/tools-enums.[ch]: remove enum GimpColorPickMode...

	* app/widgets/widgets-enums.[ch]: ...and add it here.

	* app/widgets/gimpgradienteditor.c: merge separate functions for
	picking FG and BG colors and update the new color area from the
	merged function.


svn path=/trunk/; revision=21863
This commit is contained in:
Michael Natterer 2007-02-07 17:53:16 +00:00 committed by Michael Natterer
parent ab406a1b07
commit fc761f6ed5
6 changed files with 99 additions and 109 deletions

View file

@ -1,3 +1,13 @@
2007-02-07 Michael Natterer <mitch@gimp.org>
* app/tools/tools-enums.[ch]: remove enum GimpColorPickMode...
* app/widgets/widgets-enums.[ch]: ...and add it here.
* app/widgets/gimpgradienteditor.c: merge separate functions for
picking FG and BG colors and update the new color area from the
merged function.
2007-02-07 Sven Neumann <sven@gimp.org>
* app/dialogs/preferences-dialog.c

View file

@ -9,38 +9,6 @@
#include "gimp-intl.h"
/* enumerations from "./tools-enums.h" */
GType
gimp_color_pick_mode_get_type (void)
{
static const GEnumValue values[] =
{
{ GIMP_COLOR_PICK_MODE_NONE, "GIMP_COLOR_PICK_MODE_NONE", "none" },
{ GIMP_COLOR_PICK_MODE_FOREGROUND, "GIMP_COLOR_PICK_MODE_FOREGROUND", "foreground" },
{ GIMP_COLOR_PICK_MODE_BACKGROUND, "GIMP_COLOR_PICK_MODE_BACKGROUND", "background" },
{ GIMP_COLOR_PICK_MODE_PALETTE, "GIMP_COLOR_PICK_MODE_PALETTE", "palette" },
{ 0, NULL, NULL }
};
static const GimpEnumDesc descs[] =
{
{ GIMP_COLOR_PICK_MODE_NONE, N_("Pick only"), NULL },
{ GIMP_COLOR_PICK_MODE_FOREGROUND, N_("Set foreground color"), NULL },
{ GIMP_COLOR_PICK_MODE_BACKGROUND, N_("Set background color"), NULL },
{ GIMP_COLOR_PICK_MODE_PALETTE, N_("Add to palette"), NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (! type)
{
type = g_enum_register_static ("GimpColorPickMode", values);
gimp_enum_set_value_descriptions (type, descs);
}
return type;
}
GType
gimp_rectangle_guide_get_type (void)
{

View file

@ -23,19 +23,6 @@
* these enums are registered with the type system
*/
#define GIMP_TYPE_COLOR_PICK_MODE (gimp_color_pick_mode_get_type ())
GType gimp_color_pick_mode_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_COLOR_PICK_MODE_NONE, /*< desc="Pick only" >*/
GIMP_COLOR_PICK_MODE_FOREGROUND, /*< desc="Set foreground color" >*/
GIMP_COLOR_PICK_MODE_BACKGROUND, /*< desc="Set background color" >*/
GIMP_COLOR_PICK_MODE_PALETTE /*< desc="Add to palette" >*/
} GimpColorPickMode;
#define GIMP_TYPE_RECTANGLE_GUIDE (gimp_rectangle_guide_get_type ())
GType gimp_rectangle_guide_get_type (void) G_GNUC_CONST;

View file

@ -157,9 +157,8 @@ static gboolean view_events (GtkWidget *widget,
static void view_set_hint (GimpGradientEditor *editor,
gint x);
static void view_set_foreground (GimpGradientEditor *editor,
gint x);
static void view_set_background (GimpGradientEditor *editor,
static void view_pick_color (GimpGradientEditor *editor,
GimpColorPickMode mode,
gint x);
/* Gradient control functions */
@ -868,10 +867,11 @@ view_events (GtkWidget *widget,
if (editor->view_button_down)
{
if (mevent->state & GDK_CONTROL_MASK)
view_set_background (editor, x);
else
view_set_foreground (editor, x);
view_pick_color (editor,
(mevent->state & GDK_CONTROL_MASK) ?
GIMP_COLOR_PICK_MODE_BACKGROUND :
GIMP_COLOR_PICK_MODE_FOREGROUND,
x);
}
else
{
@ -892,10 +892,12 @@ view_events (GtkWidget *widget,
case 1:
editor->view_last_x = x;
editor->view_button_down = TRUE;
if (bevent->state & GDK_CONTROL_MASK)
view_set_background (editor, x);
else
view_set_foreground (editor, x);
view_pick_color (editor,
(bevent->state & GDK_CONTROL_MASK) ?
GIMP_COLOR_PICK_MODE_BACKGROUND :
GIMP_COLOR_PICK_MODE_FOREGROUND,
x);
break;
case 3:
@ -963,10 +965,12 @@ view_events (GtkWidget *widget,
editor->view_last_x = x;
editor->view_button_down = FALSE;
if (bevent->state & GDK_CONTROL_MASK)
view_set_background (editor, x);
else
view_set_foreground (editor, x);
view_pick_color (editor,
(bevent->state & GDK_CONTROL_MASK) ?
GIMP_COLOR_PICK_MODE_BACKGROUND :
GIMP_COLOR_PICK_MODE_FOREGROUND,
x);
break;
}
break;
@ -983,9 +987,9 @@ view_set_hint (GimpGradientEditor *editor,
gint x)
{
GimpDataEditor *data_editor = GIMP_DATA_EDITOR (editor);
gdouble xpos;
GimpRGB rgb;
GimpHSV hsv;
gdouble xpos;
gchar *str1;
gchar *str2;
gchar *str3;
@ -1019,24 +1023,23 @@ view_set_hint (GimpGradientEditor *editor,
}
static void
view_set_foreground (GimpGradientEditor *editor,
gint x)
view_pick_color (GimpGradientEditor *editor,
GimpColorPickMode mode,
gint x)
{
GimpGradient *gradient;
GimpRGB color;
gdouble xpos;
gchar *str2;
gchar *str3;
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
GimpDataEditor *data_editor = GIMP_DATA_EDITOR (editor);
GimpRGB color;
gdouble xpos;
gchar *str2;
gchar *str3;
xpos = control_calc_g_pos (editor, x);
gimp_gradient_get_color_at (gradient,
GIMP_DATA_EDITOR (editor)->context,
NULL, xpos, FALSE, &color);
gimp_gradient_get_color_at (GIMP_GRADIENT (data_editor->data),
data_editor->context, NULL,
xpos, FALSE, &color);
gimp_context_set_foreground (GIMP_DATA_EDITOR (editor)->context, &color);
gimp_color_area_set_color (GIMP_COLOR_AREA (editor->current_color), &color);
str2 = g_strdup_printf (_("RGB (%d, %d, %d)"),
(gint) (color.r * 255.0),
@ -1045,43 +1048,20 @@ view_set_foreground (GimpGradientEditor *editor,
str3 = g_strdup_printf ("(%0.3f, %0.3f, %0.3f)", color.r, color.g, color.b);
gradient_editor_set_hint (editor,
_("Foreground color set to:"), str2, str3, NULL);
if (mode == GIMP_COLOR_PICK_MODE_FOREGROUND)
{
gimp_context_set_foreground (data_editor->context, &color);
g_free (str2);
g_free (str3);
}
gradient_editor_set_hint (editor, _("Foreground color set to:"),
str2, str3, NULL);
}
else
{
gimp_context_set_background (data_editor->context, &color);
static void
view_set_background (GimpGradientEditor *editor,
gint x)
{
GimpGradient *gradient;
GimpRGB color;
gdouble xpos;
gchar *str2;
gchar *str3;
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
xpos = control_calc_g_pos (editor, x);
gimp_gradient_get_color_at (gradient,
GIMP_DATA_EDITOR (editor)->context,
NULL, xpos, FALSE, &color);
gimp_context_set_background (GIMP_DATA_EDITOR (editor)->context, &color);
str2 = g_strdup_printf (_("RGB (%d, %d, %d)"),
(gint) (color.r * 255.0),
(gint) (color.g * 255.0),
(gint) (color.b * 255.0));
str3 = g_strdup_printf (_("(%0.3f, %0.3f, %0.3f)"),
color.r, color.g, color.b);
gradient_editor_set_hint (editor,
_("Background color set to:"), str2, str3, NULL);
gradient_editor_set_hint (editor, _("Background color set to:"),
str2, str3, NULL);
}
g_free (str2);
g_free (str3);

View file

@ -128,6 +128,38 @@ gimp_color_frame_mode_get_type (void)
return type;
}
GType
gimp_color_pick_mode_get_type (void)
{
static const GEnumValue values[] =
{
{ GIMP_COLOR_PICK_MODE_NONE, "GIMP_COLOR_PICK_MODE_NONE", "none" },
{ GIMP_COLOR_PICK_MODE_FOREGROUND, "GIMP_COLOR_PICK_MODE_FOREGROUND", "foreground" },
{ GIMP_COLOR_PICK_MODE_BACKGROUND, "GIMP_COLOR_PICK_MODE_BACKGROUND", "background" },
{ GIMP_COLOR_PICK_MODE_PALETTE, "GIMP_COLOR_PICK_MODE_PALETTE", "palette" },
{ 0, NULL, NULL }
};
static const GimpEnumDesc descs[] =
{
{ GIMP_COLOR_PICK_MODE_NONE, N_("Pick only"), NULL },
{ GIMP_COLOR_PICK_MODE_FOREGROUND, N_("Set foreground color"), NULL },
{ GIMP_COLOR_PICK_MODE_BACKGROUND, N_("Set background color"), NULL },
{ GIMP_COLOR_PICK_MODE_PALETTE, N_("Add to palette"), NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (! type)
{
type = g_enum_register_static ("GimpColorPickMode", values);
gimp_enum_set_value_descriptions (type, descs);
}
return type;
}
GType
gimp_color_pick_state_get_type (void)
{

View file

@ -72,6 +72,19 @@ typedef enum
} GimpColorFrameMode;
#define GIMP_TYPE_COLOR_PICK_MODE (gimp_color_pick_mode_get_type ())
GType gimp_color_pick_mode_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_COLOR_PICK_MODE_NONE, /*< desc="Pick only" >*/
GIMP_COLOR_PICK_MODE_FOREGROUND, /*< desc="Set foreground color" >*/
GIMP_COLOR_PICK_MODE_BACKGROUND, /*< desc="Set background color" >*/
GIMP_COLOR_PICK_MODE_PALETTE /*< desc="Add to palette" >*/
} GimpColorPickMode;
#define GIMP_TYPE_COLOR_PICK_STATE (gimp_color_pick_state_get_type ())
GType gimp_color_pick_state_get_type (void) G_GNUC_CONST;