static gboolean gimp_levels_tool_initialize (GimpTool *tool, GimpDisplay *display, GError **error) { GimpLevelsTool *l_tool = GIMP_LEVELS_TOOL (tool); GimpImage *image = gimp_display_get_image (display); GimpDrawable *drawable = gimp_image_get_active_drawable (image); gdouble scale_factor; gdouble step_increment; gdouble page_increment; gint digits; if (! GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error)) { return FALSE; } gimp_int_combo_box_set_sensitivity (GIMP_INT_COMBO_BOX (l_tool->channel_menu), levels_menu_sensitivity, drawable, NULL); gimp_drawable_calculate_histogram (drawable, l_tool->histogram); gimp_histogram_view_set_histogram (GIMP_HISTOGRAM_VIEW (l_tool->histogram_view), l_tool->histogram); if (gimp_drawable_get_component_type (drawable) == GIMP_COMPONENT_TYPE_U8) { scale_factor = 255.0; step_increment = 1.0; page_increment = 8.0; digits = 0; } else { scale_factor = 100; step_increment = 0.01; page_increment = 1.0; digits = 2; } gimp_prop_widget_set_factor (l_tool->low_input_spinbutton, scale_factor, step_increment, page_increment, digits); gimp_prop_widget_set_factor (l_tool->high_input_spinbutton, scale_factor, step_increment, page_increment, digits); gimp_prop_widget_set_factor (l_tool->low_output_spinbutton, scale_factor, step_increment, page_increment, digits); gimp_prop_widget_set_factor (l_tool->high_output_spinbutton, scale_factor, step_increment, page_increment, digits); gtk_adjustment_configure (l_tool->gamma_linear, scale_factor / 2.0, 0, scale_factor, 0.1, 1.0, 0); return TRUE; }
static gboolean gimp_curves_tool_initialize (GimpTool *tool, GimpDisplay *display, GError **error) { GimpCurvesTool *c_tool = GIMP_CURVES_TOOL (tool); GimpImage *image = gimp_display_get_image (display); GimpDrawable *drawable = gimp_image_get_active_drawable (image); GimpHistogram *histogram; if (! GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error)) { return FALSE; } /* always pick colors */ gimp_color_tool_enable (GIMP_COLOR_TOOL (tool), GIMP_COLOR_TOOL_GET_OPTIONS (tool)); gimp_int_combo_box_set_sensitivity (GIMP_INT_COMBO_BOX (c_tool->channel_menu), curves_menu_sensitivity, drawable, NULL); histogram = gimp_histogram_new (TRUE); gimp_drawable_calculate_histogram (drawable, histogram); gimp_histogram_view_set_background (GIMP_HISTOGRAM_VIEW (c_tool->graph), histogram); g_object_unref (histogram); if (gimp_drawable_get_component_type (drawable) == GIMP_COMPONENT_TYPE_U8) { gimp_curve_view_set_range_x (GIMP_CURVE_VIEW (c_tool->graph), 0, 255); gimp_curve_view_set_range_y (GIMP_CURVE_VIEW (c_tool->graph), 0, 255); } else { gimp_curve_view_set_range_x (GIMP_CURVE_VIEW (c_tool->graph), 0, 100); gimp_curve_view_set_range_y (GIMP_CURVE_VIEW (c_tool->graph), 0, 100); } return TRUE; }