app/actions/gradient-editor-actions.c added actions and callbacks to

2006-09-01  Michael Natterer  <mitch@gimp.org>

	* app/actions/gradient-editor-actions.c
	* app/actions/gradient-editor-commands.[ch]: added actions and
	callbacks to select a gradient segment's left and right color
	type. Handle FG/BG color correctly in a few places. Use
	GimpDataEditor's context instead of the user context.

	* menus/gradient-editor-menu.xml: added the actions to the menu.

	Cleanup:

	* app/actions/palette-editor-actions.c
	* app/actions/palette-editor-commands.c: use GimpDataEditor's
	context instead of the user context.

	* app/actions/brush-editor-actions.c: remove unused context
	variable.
This commit is contained in:
Michael Natterer 2006-08-31 22:35:19 +00:00 committed by Michael Natterer
parent 875342af5d
commit 8486d32af3
8 changed files with 411 additions and 123 deletions

View File

@ -1,3 +1,22 @@
2006-09-01 Michael Natterer <mitch@gimp.org>
* app/actions/gradient-editor-actions.c
* app/actions/gradient-editor-commands.[ch]: added actions and
callbacks to select a gradient segment's left and right color
type. Handle FG/BG color correctly in a few places. Use
GimpDataEditor's context instead of the user context.
* menus/gradient-editor-menu.xml: added the actions to the menu.
Cleanup:
* app/actions/palette-editor-actions.c
* app/actions/palette-editor-commands.c: use GimpDataEditor's
context instead of the user context.
* app/actions/brush-editor-actions.c: remove unused context
variable.
2006-08-31 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpcontainerview.c

View File

@ -70,13 +70,10 @@ brush_editor_actions_update (GimpActionGroup *group,
gpointer user_data)
{
GimpDataEditor *data_editor = GIMP_DATA_EDITOR (user_data);
GimpContext *context;
GimpData *data;
gboolean editable = FALSE;
gboolean edit_active = FALSE;
context = gimp_get_user_context (group->gimp);
data = data_editor->data;
if (data)

View File

@ -46,11 +46,15 @@ static const GimpActionEntry gradient_editor_actions[] =
N_("Gradient Editor Menu"), NULL, NULL, NULL,
GIMP_HELP_GRADIENT_EDITOR_DIALOG },
{ "gradient-editor-left-color-type", NULL,
N_("Left Color Type") },
{ "gradient-editor-load-left-color", GTK_STOCK_REVERT_TO_SAVED,
N_("_Load Left Color From") },
{ "gradient-editor-save-left-color", GTK_STOCK_SAVE,
N_("_Save Left Color To") },
{ "gradient-editor-right-color-type", NULL,
N_("Right Color Type") },
{ "gradient-editor-load-right-color", GTK_STOCK_REVERT_TO_SAVED,
N_("Load Right Color Fr_om") },
{ "gradient-editor-save-right-color", GTK_STOCK_SAVE,
@ -248,6 +252,62 @@ static const GimpEnumActionEntry gradient_editor_save_right_actions[] =
#undef SAVE_RIGHT_TO
static const GimpRadioActionEntry gradient_editor_left_color_type_actions[] =
{
{ "gradient-editor-left-color-fixed", NULL,
N_("_Fixed"), NULL, NULL,
GIMP_GRADIENT_COLOR_FIXED,
GIMP_HELP_GRADIENT_EDITOR_LEFT_COLOR },
{ "gradient-editor-left-color-foreground", NULL,
N_("F_oreground Color"), NULL, NULL,
GIMP_GRADIENT_COLOR_FOREGROUND,
GIMP_HELP_GRADIENT_EDITOR_LEFT_COLOR },
{ "gradient-editor-left-color-foreground-transparent", NULL,
N_("Fo_reground Color (Transparent)"), NULL, NULL,
GIMP_GRADIENT_COLOR_FOREGROUND_TRANSPARENT,
GIMP_HELP_GRADIENT_EDITOR_LEFT_COLOR },
{ "gradient-editor-left-color-background", NULL,
N_("_Background Color"), NULL, NULL,
GIMP_GRADIENT_COLOR_BACKGROUND,
GIMP_HELP_GRADIENT_EDITOR_LEFT_COLOR },
{ "gradient-editor-left-color-background-transparent", NULL,
N_("B_ackground Color (Transparent)"), NULL, NULL,
GIMP_GRADIENT_COLOR_BACKGROUND_TRANSPARENT,
GIMP_HELP_GRADIENT_EDITOR_LEFT_COLOR }
};
static const GimpRadioActionEntry gradient_editor_right_color_type_actions[] =
{
{ "gradient-editor-right-color-fixed", NULL,
N_("_Fixed"), NULL, NULL,
GIMP_GRADIENT_COLOR_FIXED,
GIMP_HELP_GRADIENT_EDITOR_RIGHT_COLOR },
{ "gradient-editor-right-color-foreground", NULL,
N_("F_oreground Color"), NULL, NULL,
GIMP_GRADIENT_COLOR_FOREGROUND,
GIMP_HELP_GRADIENT_EDITOR_RIGHT_COLOR },
{ "gradient-editor-right-color-foreground-transparent", NULL,
N_("Fo_reground Color (Transparent)"), NULL, NULL,
GIMP_GRADIENT_COLOR_FOREGROUND_TRANSPARENT,
GIMP_HELP_GRADIENT_EDITOR_RIGHT_COLOR },
{ "gradient-editor-right-color-background", NULL,
N_("_Background Color"), NULL, NULL,
GIMP_GRADIENT_COLOR_BACKGROUND,
GIMP_HELP_GRADIENT_EDITOR_RIGHT_COLOR },
{ "gradient-editor-right-color-background-transparent", NULL,
N_("B_ackground Color (Transparent)"), NULL, NULL,
GIMP_GRADIENT_COLOR_BACKGROUND_TRANSPARENT,
GIMP_HELP_GRADIENT_EDITOR_RIGHT_COLOR }
};
static const GimpRadioActionEntry gradient_editor_blending_actions[] =
{
{ "gradient-editor-blending-linear", NULL,
@ -358,6 +418,20 @@ gradient_editor_actions_setup (GimpActionGroup *group)
G_N_ELEMENTS (gradient_editor_save_right_actions),
G_CALLBACK (gradient_editor_save_right_cmd_callback));
gimp_action_group_add_radio_actions (group,
gradient_editor_left_color_type_actions,
G_N_ELEMENTS (gradient_editor_left_color_type_actions),
NULL,
0,
G_CALLBACK (gradient_editor_left_color_type_cmd_callback));
gimp_action_group_add_radio_actions (group,
gradient_editor_right_color_type_actions,
G_N_ELEMENTS (gradient_editor_right_color_type_actions),
NULL,
0,
G_CALLBACK (gradient_editor_right_color_type_cmd_callback));
gimp_action_group_add_radio_actions (group,
gradient_editor_blending_actions,
G_N_ELEMENTS (gradient_editor_blending_actions),
@ -385,41 +459,67 @@ gradient_editor_actions_update (GimpActionGroup *group,
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
GimpDataEditor *data_editor = GIMP_DATA_EDITOR (data);
GimpGradient *gradient;
GimpContext *context;
gboolean editable = FALSE;
GimpGradientSegment *left_seg = NULL;
GimpGradientSegment *right_seg = NULL;
GimpRGB left_color;
GimpRGB right_color;
GimpRGB left_seg_color;
GimpRGB right_seg_color;
GimpRGB fg;
GimpRGB bg;
gboolean blending_equal = TRUE;
gboolean coloring_equal = TRUE;
gboolean left_editable = TRUE;
gboolean right_editable = TRUE;
gboolean selection = FALSE;
gboolean delete = FALSE;
gboolean edit_active = FALSE;
gradient = GIMP_GRADIENT (data_editor->data);
context = gimp_get_user_context (data_editor->data_factory->gimp);
if (gradient)
{
GimpGradientSegmentType type;
GimpGradientSegmentColor color;
GimpGradientSegment *left_seg;
GimpGradientSegment *right_seg;
GimpGradientSegment *seg, *aseg;
if (data_editor->data_editable)
editable = TRUE;
gimp_gradient_get_color_at (gradient, data_editor->context,
editor->control_sel_l,
editor->control_sel_l->left, FALSE,
&left_color);
if (editor->control_sel_l->prev)
left_seg = editor->control_sel_l->prev;
else
left_seg = gimp_gradient_segment_get_last (editor->control_sel_l);
gimp_gradient_get_color_at (gradient, data_editor->context,
left_seg, left_seg->right, FALSE,
&left_seg_color);
gimp_gradient_get_color_at (gradient, data_editor->context,
editor->control_sel_r,
editor->control_sel_r->right, FALSE,
&right_color);
if (editor->control_sel_r->next)
right_seg = editor->control_sel_r->next;
else
right_seg = gimp_gradient_segment_get_first (editor->control_sel_r);
gimp_gradient_get_color_at (gradient, data_editor->context,
right_seg, right_seg->left, FALSE,
&right_seg_color);
left_editable = (editor->control_sel_l->left_color_type ==
GIMP_GRADIENT_COLOR_FIXED);
right_editable = (editor->control_sel_r->right_color_type ==
GIMP_GRADIENT_COLOR_FIXED);
type = editor->control_sel_l->type;
color = editor->control_sel_l->color;
@ -439,10 +539,10 @@ gradient_editor_actions_update (GimpActionGroup *group,
delete = (editor->control_sel_l->prev || editor->control_sel_r->next);
}
if (context)
if (data_editor->context)
{
gimp_context_get_foreground (context, &fg);
gimp_context_get_background (context, &bg);
gimp_context_get_foreground (data_editor->context, &fg);
gimp_context_get_background (data_editor->context, &bg);
}
/* pretend the gradient not being editable while the dialog is
@ -452,6 +552,12 @@ gradient_editor_actions_update (GimpActionGroup *group,
if (! GTK_WIDGET_SENSITIVE (editor))
editable = FALSE;
if (! editable)
{
left_editable = FALSE;
right_editable = FALSE;
}
edit_active = gimp_data_editor_get_edit_active (data_editor);
#define SET_ACTIVE(action,condition) \
@ -465,36 +571,66 @@ gradient_editor_actions_update (GimpActionGroup *group,
#define SET_VISIBLE(action,condition) \
gimp_action_group_set_action_visible (group, action, (condition) != 0)
SET_SENSITIVE ("gradient-editor-left-color", editable);
SET_SENSITIVE ("gradient-editor-left-color-fixed", editable);
SET_SENSITIVE ("gradient-editor-left-color-foreground", editable);
SET_SENSITIVE ("gradient-editor-left-color-foreground-transparent", editable);
SET_SENSITIVE ("gradient-editor-left-color-background", editable);
SET_SENSITIVE ("gradient-editor-left-color-background-transparent", editable);
if (gradient)
{
switch (editor->control_sel_l->left_color_type)
{
case GIMP_GRADIENT_COLOR_FIXED:
SET_ACTIVE ("gradient-editor-left-color-fixed", TRUE);
break;
case GIMP_GRADIENT_COLOR_FOREGROUND:
SET_ACTIVE ("gradient-editor-left-color-foreground", TRUE);
break;
case GIMP_GRADIENT_COLOR_FOREGROUND_TRANSPARENT:
SET_ACTIVE ("gradient-editor-left-color-foreground-transparent", TRUE);
break;
case GIMP_GRADIENT_COLOR_BACKGROUND:
SET_ACTIVE ("gradient-editor-left-color-background", TRUE);
break;
case GIMP_GRADIENT_COLOR_BACKGROUND_TRANSPARENT:
SET_ACTIVE ("gradient-editor-left-color-background-transparent", TRUE);
break;
}
}
SET_SENSITIVE ("gradient-editor-left-color", left_editable);
SET_SENSITIVE ("gradient-editor-load-left-left-neighbor", editable);
SET_SENSITIVE ("gradient-editor-load-left-right-endpoint", editable);
if (gradient)
{
SET_COLOR ("gradient-editor-left-color",
&editor->control_sel_l->left_color, FALSE);
&left_color, FALSE);
SET_COLOR ("gradient-editor-load-left-left-neighbor",
&left_seg->right_color, FALSE);
&left_seg_color, FALSE);
SET_COLOR ("gradient-editor-load-left-right-endpoint",
&editor->control_sel_r->right_color, FALSE);
&right_color, FALSE);
}
SET_SENSITIVE ("gradient-editor-load-left-fg", editable);
SET_SENSITIVE ("gradient-editor-load-left-bg", editable);
SET_SENSITIVE ("gradient-editor-load-left-fg", left_editable);
SET_SENSITIVE ("gradient-editor-load-left-bg", left_editable);
SET_COLOR ("gradient-editor-load-left-fg", context ? &fg : NULL, FALSE);
SET_COLOR ("gradient-editor-load-left-bg", context ? &bg : NULL, FALSE);
SET_COLOR ("gradient-editor-load-left-fg",
data_editor->context ? &fg : NULL, FALSE);
SET_COLOR ("gradient-editor-load-left-bg",
data_editor->context ? &bg : NULL, FALSE);
SET_SENSITIVE ("gradient-editor-load-left-01", editable);
SET_SENSITIVE ("gradient-editor-load-left-02", editable);
SET_SENSITIVE ("gradient-editor-load-left-03", editable);
SET_SENSITIVE ("gradient-editor-load-left-04", editable);
SET_SENSITIVE ("gradient-editor-load-left-05", editable);
SET_SENSITIVE ("gradient-editor-load-left-06", editable);
SET_SENSITIVE ("gradient-editor-load-left-07", editable);
SET_SENSITIVE ("gradient-editor-load-left-08", editable);
SET_SENSITIVE ("gradient-editor-load-left-09", editable);
SET_SENSITIVE ("gradient-editor-load-left-10", editable);
SET_SENSITIVE ("gradient-editor-load-left-01", left_editable);
SET_SENSITIVE ("gradient-editor-load-left-02", left_editable);
SET_SENSITIVE ("gradient-editor-load-left-03", left_editable);
SET_SENSITIVE ("gradient-editor-load-left-04", left_editable);
SET_SENSITIVE ("gradient-editor-load-left-05", left_editable);
SET_SENSITIVE ("gradient-editor-load-left-06", left_editable);
SET_SENSITIVE ("gradient-editor-load-left-07", left_editable);
SET_SENSITIVE ("gradient-editor-load-left-08", left_editable);
SET_SENSITIVE ("gradient-editor-load-left-09", left_editable);
SET_SENSITIVE ("gradient-editor-load-left-10", left_editable);
SET_COLOR ("gradient-editor-load-left-01", &editor->saved_colors[0], TRUE);
SET_COLOR ("gradient-editor-load-left-02", &editor->saved_colors[1], TRUE);
@ -529,36 +665,66 @@ gradient_editor_actions_update (GimpActionGroup *group,
SET_COLOR ("gradient-editor-save-left-09", &editor->saved_colors[8], TRUE);
SET_COLOR ("gradient-editor-save-left-10", &editor->saved_colors[9], TRUE);
SET_SENSITIVE ("gradient-editor-right-color", editable);
SET_SENSITIVE ("gradient-editor-right-color-fixed", editable);
SET_SENSITIVE ("gradient-editor-right-color-foreground", editable);
SET_SENSITIVE ("gradient-editor-right-color-foreground-transparent", editable);
SET_SENSITIVE ("gradient-editor-right-color-background", editable);
SET_SENSITIVE ("gradient-editor-right-color-background-transparent", editable);
if (gradient)
{
switch (editor->control_sel_r->right_color_type)
{
case GIMP_GRADIENT_COLOR_FIXED:
SET_ACTIVE ("gradient-editor-right-color-fixed", TRUE);
break;
case GIMP_GRADIENT_COLOR_FOREGROUND:
SET_ACTIVE ("gradient-editor-right-color-foreground", TRUE);
break;
case GIMP_GRADIENT_COLOR_FOREGROUND_TRANSPARENT:
SET_ACTIVE ("gradient-editor-right-color-foreground-transparent", TRUE);
break;
case GIMP_GRADIENT_COLOR_BACKGROUND:
SET_ACTIVE ("gradient-editor-right-color-background", TRUE);
break;
case GIMP_GRADIENT_COLOR_BACKGROUND_TRANSPARENT:
SET_ACTIVE ("gradient-editor-right-color-background-transparent", TRUE);
break;
}
}
SET_SENSITIVE ("gradient-editor-right-color", right_editable);
SET_SENSITIVE ("gradient-editor-load-right-right-neighbor", editable);
SET_SENSITIVE ("gradient-editor-load-right-left-endpoint", editable);
if (gradient)
{
SET_COLOR ("gradient-editor-right-color",
&editor->control_sel_r->right_color, FALSE);
&right_color, FALSE);
SET_COLOR ("gradient-editor-load-right-right-neighbor",
&right_seg->left_color, FALSE);
&right_seg_color, FALSE);
SET_COLOR ("gradient-editor-load-right-left-endpoint",
&editor->control_sel_l->left_color, FALSE);
&left_color, FALSE);
}
SET_SENSITIVE ("gradient-editor-load-right-fg", editable);
SET_SENSITIVE ("gradient-editor-load-right-bg", editable);
SET_SENSITIVE ("gradient-editor-load-right-fg", right_editable);
SET_SENSITIVE ("gradient-editor-load-right-bg", right_editable);
SET_COLOR ("gradient-editor-load-right-fg", context ? &fg : NULL, FALSE);
SET_COLOR ("gradient-editor-load-right-bg", context ? &bg : NULL, FALSE);
SET_COLOR ("gradient-editor-load-right-fg",
data_editor->context ? &fg : NULL, FALSE);
SET_COLOR ("gradient-editor-load-right-bg",
data_editor->context ? &bg : NULL, FALSE);
SET_SENSITIVE ("gradient-editor-load-right-01", editable);
SET_SENSITIVE ("gradient-editor-load-right-02", editable);
SET_SENSITIVE ("gradient-editor-load-right-03", editable);
SET_SENSITIVE ("gradient-editor-load-right-04", editable);
SET_SENSITIVE ("gradient-editor-load-right-05", editable);
SET_SENSITIVE ("gradient-editor-load-right-06", editable);
SET_SENSITIVE ("gradient-editor-load-right-07", editable);
SET_SENSITIVE ("gradient-editor-load-right-08", editable);
SET_SENSITIVE ("gradient-editor-load-right-09", editable);
SET_SENSITIVE ("gradient-editor-load-right-10", editable);
SET_SENSITIVE ("gradient-editor-load-right-01", right_editable);
SET_SENSITIVE ("gradient-editor-load-right-02", right_editable);
SET_SENSITIVE ("gradient-editor-load-right-03", right_editable);
SET_SENSITIVE ("gradient-editor-load-right-04", right_editable);
SET_SENSITIVE ("gradient-editor-load-right-05", right_editable);
SET_SENSITIVE ("gradient-editor-load-right-06", right_editable);
SET_SENSITIVE ("gradient-editor-load-right-07", right_editable);
SET_SENSITIVE ("gradient-editor-load-right-08", right_editable);
SET_SENSITIVE ("gradient-editor-load-right-09", right_editable);
SET_SENSITIVE ("gradient-editor-load-right-10", right_editable);
SET_COLOR ("gradient-editor-load-right-01", &editor->saved_colors[0], TRUE);
SET_COLOR ("gradient-editor-load-right-02", &editor->saved_colors[1], TRUE);

View File

@ -106,21 +106,58 @@ gradient_editor_left_color_cmd_callback (GtkAction *action,
gtk_window_present (GTK_WINDOW (editor->color_dialog));
}
void
gradient_editor_left_color_type_cmd_callback (GtkAction *action,
GtkAction *current,
gpointer data)
{
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
GimpGradient *gradient;
gint value;
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
if (gradient && value >= 0)
{
GimpGradientColor color_type = value;
GimpRGB color;
gimp_gradient_get_color_at (gradient,
GIMP_DATA_EDITOR (editor)->context,
editor->control_sel_l,
editor->control_sel_l->left, FALSE,
&color);
gimp_data_freeze (GIMP_DATA (gradient));
gimp_gradient_segment_set_left_color_type (gradient,
editor->control_sel_l,
color_type);
if (color_type == GIMP_GRADIENT_COLOR_FIXED)
gimp_gradient_segment_set_left_color (gradient,
editor->control_sel_l,
&color);
gimp_data_thaw (GIMP_DATA (gradient));
}
}
void
gradient_editor_load_left_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
GimpDataEditor *data_editor = GIMP_DATA_EDITOR (data);
GimpGradient *gradient;
GimpContext *context;
GimpGradientSegment *seg;
GimpRGB color;
GimpGradientColor color_type = GIMP_GRADIENT_COLOR_FIXED;
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
context =
gimp_get_user_context (GIMP_DATA_EDITOR (editor)->data_factory->gimp);
gradient = GIMP_GRADIENT (data_editor->data);
switch (value)
{
@ -130,19 +167,21 @@ gradient_editor_load_left_cmd_callback (GtkAction *action,
else
seg = gimp_gradient_segment_get_last (editor->control_sel_l);
color = seg->right_color;
color = seg->right_color;
color_type = seg->right_color_type;
break;
case GRADIENT_EDITOR_COLOR_OTHER_ENDPOINT:
color = editor->control_sel_r->right_color;
color = editor->control_sel_r->right_color;
color_type = editor->control_sel_l->right_color_type;
break;
case GRADIENT_EDITOR_COLOR_FOREGROUND:
gimp_context_get_foreground (context, &color);
gimp_context_get_foreground (data_editor->context, &color);
break;
case GRADIENT_EDITOR_COLOR_BACKGROUND:
gimp_context_get_background (context, &color);
gimp_context_get_background (data_editor->context, &color);
break;
default: /* Load a color */
@ -150,12 +189,19 @@ gradient_editor_load_left_cmd_callback (GtkAction *action,
break;
}
gimp_data_freeze (GIMP_DATA (gradient));
gimp_gradient_segment_range_blend (gradient,
editor->control_sel_l,
editor->control_sel_r,
&color,
&editor->control_sel_r->right_color,
TRUE, TRUE);
gimp_gradient_segment_set_left_color_type (gradient,
editor->control_sel_l,
color_type);
gimp_data_thaw (GIMP_DATA (gradient));
}
void
@ -210,21 +256,58 @@ gradient_editor_right_color_cmd_callback (GtkAction *action,
gtk_window_present (GTK_WINDOW (editor->color_dialog));
}
void
gradient_editor_right_color_type_cmd_callback (GtkAction *action,
GtkAction *current,
gpointer data)
{
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
GimpGradient *gradient;
gint value;
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
if (gradient && value >= 0)
{
GimpGradientColor color_type = value;
GimpRGB color;
gimp_gradient_get_color_at (gradient,
GIMP_DATA_EDITOR (editor)->context,
editor->control_sel_r,
editor->control_sel_r->right, FALSE,
&color);
gimp_data_freeze (GIMP_DATA (gradient));
gimp_gradient_segment_set_right_color_type (gradient,
editor->control_sel_r,
color_type);
if (color_type == GIMP_GRADIENT_COLOR_FIXED)
gimp_gradient_segment_set_right_color (gradient,
editor->control_sel_r,
&color);
gimp_data_thaw (GIMP_DATA (gradient));
}
}
void
gradient_editor_load_right_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
GimpDataEditor *data_editor = GIMP_DATA_EDITOR (data);
GimpGradient *gradient;
GimpContext *context;
GimpGradientSegment *seg;
GimpRGB color;
GimpGradientColor color_type = GIMP_GRADIENT_COLOR_FIXED;
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
context =
gimp_get_user_context (GIMP_DATA_EDITOR (editor)->data_factory->gimp);
gradient = GIMP_GRADIENT (data_editor->data);
switch (value)
{
@ -234,19 +317,21 @@ gradient_editor_load_right_cmd_callback (GtkAction *action,
else
seg = gimp_gradient_segment_get_first (editor->control_sel_r);
color = seg->left_color;
color = seg->left_color;
color_type = seg->left_color_type;
break;
case GRADIENT_EDITOR_COLOR_OTHER_ENDPOINT:
color = editor->control_sel_l->left_color;
color = editor->control_sel_l->left_color;
color_type = editor->control_sel_l->left_color_type;
break;
case GRADIENT_EDITOR_COLOR_FOREGROUND:
gimp_context_get_foreground (context, &color);
gimp_context_get_foreground (data_editor->context, &color);
break;
case GRADIENT_EDITOR_COLOR_BACKGROUND:
gimp_context_get_background (context, &color);
gimp_context_get_background (data_editor->context, &color);
break;
default: /* Load a color */
@ -254,12 +339,19 @@ gradient_editor_load_right_cmd_callback (GtkAction *action,
break;
}
gimp_data_freeze (GIMP_DATA (gradient));
gimp_gradient_segment_range_blend (gradient,
editor->control_sel_l,
editor->control_sel_r,
&editor->control_sel_l->left_color,
&color,
TRUE, TRUE);
gimp_gradient_segment_set_right_color_type (gradient,
editor->control_sel_l,
color_type);
gimp_data_thaw (GIMP_DATA (gradient));
}
void

View File

@ -30,54 +30,60 @@ enum
};
void gradient_editor_left_color_cmd_callback (GtkAction *action,
gpointer data);
void gradient_editor_load_left_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void gradient_editor_save_left_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void gradient_editor_left_color_cmd_callback (GtkAction *action,
gpointer data);
void gradient_editor_left_color_type_cmd_callback (GtkAction *action,
GtkAction *current,
gpointer data);
void gradient_editor_load_left_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void gradient_editor_save_left_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void gradient_editor_right_color_cmd_callback (GtkAction *action,
gpointer data);
void gradient_editor_load_right_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void gradient_editor_save_right_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void gradient_editor_right_color_cmd_callback (GtkAction *action,
gpointer data);
void gradient_editor_right_color_type_cmd_callback (GtkAction *action,
GtkAction *current,
gpointer data);
void gradient_editor_load_right_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void gradient_editor_save_right_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void gradient_editor_blending_func_cmd_callback (GtkAction *action,
GtkAction *current,
gpointer data);
void gradient_editor_coloring_type_cmd_callback (GtkAction *action,
GtkAction *current,
gpointer data);
void gradient_editor_blending_func_cmd_callback (GtkAction *action,
GtkAction *current,
gpointer data);
void gradient_editor_coloring_type_cmd_callback (GtkAction *action,
GtkAction *current,
gpointer data);
void gradient_editor_flip_cmd_callback (GtkAction *action,
gpointer data);
void gradient_editor_replicate_cmd_callback (GtkAction *action,
gpointer data);
void gradient_editor_split_midpoint_cmd_callback (GtkAction *action,
gpointer data);
void gradient_editor_split_uniformly_cmd_callback (GtkAction *action,
gpointer data);
void gradient_editor_delete_cmd_callback (GtkAction *action,
gpointer data);
void gradient_editor_recenter_cmd_callback (GtkAction *action,
gpointer data);
void gradient_editor_redistribute_cmd_callback (GtkAction *action,
gpointer data);
void gradient_editor_flip_cmd_callback (GtkAction *action,
gpointer data);
void gradient_editor_replicate_cmd_callback (GtkAction *action,
gpointer data);
void gradient_editor_split_midpoint_cmd_callback (GtkAction *action,
gpointer data);
void gradient_editor_split_uniformly_cmd_callback (GtkAction *action,
gpointer data);
void gradient_editor_delete_cmd_callback (GtkAction *action,
gpointer data);
void gradient_editor_recenter_cmd_callback (GtkAction *action,
gpointer data);
void gradient_editor_redistribute_cmd_callback (GtkAction *action,
gpointer data);
void gradient_editor_blend_color_cmd_callback (GtkAction *action,
gpointer data);
void gradient_editor_blend_opacity_cmd_callback (GtkAction *action,
gpointer data);
void gradient_editor_blend_color_cmd_callback (GtkAction *action,
gpointer data);
void gradient_editor_blend_opacity_cmd_callback (GtkAction *action,
gpointer data);
void gradient_editor_zoom_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void gradient_editor_zoom_cmd_callback (GtkAction *action,
gint value,
gpointer data);
#endif /* __GRADIENT_EDITOR_COMMANDS_H__ */

View File

@ -131,15 +131,12 @@ palette_editor_actions_update (GimpActionGroup *group,
{
GimpPaletteEditor *editor = GIMP_PALETTE_EDITOR (user_data);
GimpDataEditor *data_editor = GIMP_DATA_EDITOR (user_data);
GimpContext *context;
GimpData *data;
gboolean editable = FALSE;
GimpRGB fg;
GimpRGB bg;
gboolean edit_active = FALSE;
context = gimp_get_user_context (group->gimp);
data = data_editor->data;
if (data)
@ -148,10 +145,10 @@ palette_editor_actions_update (GimpActionGroup *group,
editable = TRUE;
}
if (context)
if (data_editor->context)
{
gimp_context_get_foreground (context, &fg);
gimp_context_get_background (context, &bg);
gimp_context_get_foreground (data_editor->context, &fg);
gimp_context_get_background (data_editor->context, &bg);
}
edit_active = gimp_data_editor_get_edit_active (data_editor);
@ -169,8 +166,8 @@ palette_editor_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("palette-editor-new-color-fg", editable);
SET_SENSITIVE ("palette-editor-new-color-bg", editable);
SET_COLOR ("palette-editor-new-color-fg", context ? &fg : NULL);
SET_COLOR ("palette-editor-new-color-bg", context ? &bg : NULL);
SET_COLOR ("palette-editor-new-color-fg", data_editor->context ? &fg : NULL);
SET_COLOR ("palette-editor-new-color-bg", data_editor->context ? &bg : NULL);
SET_SENSITIVE ("palette-editor-zoom-out", data);
SET_SENSITIVE ("palette-editor-zoom-in", data);

View File

@ -104,15 +104,12 @@ palette_editor_new_color_cmd_callback (GtkAction *action,
if (data_editor->data_editable)
{
GimpPalette *palette = GIMP_PALETTE (data_editor->data);
GimpContext *context;
GimpRGB color;
context = gimp_get_user_context (data_editor->data_factory->gimp);
if (value)
gimp_context_get_background (context, &color);
gimp_context_get_background (data_editor->context, &color);
else
gimp_context_get_foreground (context, &color);
gimp_context_get_foreground (data_editor->context, &color);
editor->color = gimp_palette_add_entry (palette, -1, NULL, &color);
}

View File

@ -3,6 +3,13 @@
<ui>
<popup action="gradient-editor-popup">
<menu action="gradient-editor-left-color-type">
<menuitem action="gradient-editor-left-color-fixed" />
<menuitem action="gradient-editor-left-color-foreground" />
<menuitem action="gradient-editor-left-color-foreground-transparent" />
<menuitem action="gradient-editor-left-color-background" />
<menuitem action="gradient-editor-left-color-background-transparent" />
</menu>
<menuitem action="gradient-editor-left-color" />
<menu action="gradient-editor-load-left-color">
<menuitem action="gradient-editor-load-left-left-neighbor" />
@ -34,6 +41,13 @@
<menuitem action="gradient-editor-save-left-10" />
</menu>
<separator />
<menu action="gradient-editor-right-color-type">
<menuitem action="gradient-editor-right-color-fixed" />
<menuitem action="gradient-editor-right-color-foreground" />
<menuitem action="gradient-editor-right-color-foreground-transparent" />
<menuitem action="gradient-editor-right-color-background" />
<menuitem action="gradient-editor-right-color-background-transparent" />
</menu>
<menuitem action="gradient-editor-right-color" />
<menu action="gradient-editor-load-right-color">
<menuitem action="gradient-editor-load-right-right-neighbor" />