app: Clean up internal gradient construction

Move code that is not shared between all gradients out of
gimp_gradients_add_gradient() and group the code with comments.
This commit is contained in:
Martin Nordholts 2009-08-15 11:48:36 +02:00
parent e9905896fc
commit 98aaae7cac
1 changed files with 13 additions and 5 deletions

View File

@ -56,24 +56,35 @@ gimp_gradients_init (Gimp *gimp)
g_return_if_fail (GIMP_IS_GIMP (gimp)); g_return_if_fail (GIMP_IS_GIMP (gimp));
/* FG to BG (RGB) */
gradient = gimp_gradients_add_gradient (gimp, gradient = gimp_gradients_add_gradient (gimp,
_("FG to BG (RGB)"), _("FG to BG (RGB)"),
FG_BG_RGB_KEY); FG_BG_RGB_KEY);
gradient->segments->left_color_type = GIMP_GRADIENT_COLOR_FOREGROUND;
gradient->segments->right_color_type = GIMP_GRADIENT_COLOR_BACKGROUND;
gimp_context_set_gradient (gimp->user_context, gradient); gimp_context_set_gradient (gimp->user_context, gradient);
/* FG to BG (HSV counter-clockwise) */
gradient = gimp_gradients_add_gradient (gimp, gradient = gimp_gradients_add_gradient (gimp,
_("FG to BG (HSV counter-clockwise)"), _("FG to BG (HSV counter-clockwise)"),
FG_BG_HSV_CCW_KEY); FG_BG_HSV_CCW_KEY);
gradient->segments->color = GIMP_GRADIENT_SEGMENT_HSV_CCW; gradient->segments->left_color_type = GIMP_GRADIENT_COLOR_FOREGROUND;
gradient->segments->right_color_type = GIMP_GRADIENT_COLOR_BACKGROUND;
gradient->segments->color = GIMP_GRADIENT_SEGMENT_HSV_CCW;
/* FG to BG (HSV clockwise hue) */
gradient = gimp_gradients_add_gradient (gimp, gradient = gimp_gradients_add_gradient (gimp,
_("FG to BG (HSV clockwise hue)"), _("FG to BG (HSV clockwise hue)"),
FG_BG_HSV_CW_KEY); FG_BG_HSV_CW_KEY);
gradient->segments->color = GIMP_GRADIENT_SEGMENT_HSV_CW; gradient->segments->left_color_type = GIMP_GRADIENT_COLOR_FOREGROUND;
gradient->segments->right_color_type = GIMP_GRADIENT_COLOR_BACKGROUND;
gradient->segments->color = GIMP_GRADIENT_SEGMENT_HSV_CW;
/* FG to Transparent */
gradient = gimp_gradients_add_gradient (gimp, gradient = gimp_gradients_add_gradient (gimp,
_("FG to Transparent"), _("FG to Transparent"),
FG_TRANSPARENT_KEY); FG_TRANSPARENT_KEY);
gradient->segments->left_color_type = GIMP_GRADIENT_COLOR_FOREGROUND;
gradient->segments->right_color_type = GIMP_GRADIENT_COLOR_FOREGROUND_TRANSPARENT; gradient->segments->right_color_type = GIMP_GRADIENT_COLOR_FOREGROUND_TRANSPARENT;
} }
@ -89,9 +100,6 @@ gimp_gradients_add_gradient (Gimp *gimp,
gimp_data_make_internal (GIMP_DATA (gradient), id); gimp_data_make_internal (GIMP_DATA (gradient), id);
gradient->segments->left_color_type = GIMP_GRADIENT_COLOR_FOREGROUND;
gradient->segments->right_color_type = GIMP_GRADIENT_COLOR_BACKGROUND;
gimp_container_add (gimp_data_factory_get_container (gimp->gradient_factory), gimp_container_add (gimp_data_factory_get_container (gimp->gradient_factory),
GIMP_OBJECT (gradient)); GIMP_OBJECT (gradient));
g_object_unref (gradient); g_object_unref (gradient);