static void gimp_histogram_view_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { GimpHistogramView *view = GIMP_HISTOGRAM_VIEW (object); switch (property_id) { case PROP_CHANNEL: view->channel = g_value_get_enum (value); gtk_widget_queue_draw (GTK_WIDGET (view)); break; case PROP_SCALE: view->scale = g_value_get_enum (value); gtk_widget_queue_draw (GTK_WIDGET (view)); break; case PROP_BORDER_WIDTH: view->border_width = g_value_get_int (value); gtk_widget_queue_resize (GTK_WIDGET (view)); break; case PROP_SUBDIVISIONS: view->subdivisions = g_value_get_int (value); gtk_widget_queue_draw (GTK_WIDGET (view)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } }
static gboolean gimp_histogram_view_button_press (GtkWidget *widget, GdkEventButton *bevent) { GimpHistogramView *view = GIMP_HISTOGRAM_VIEW (widget); if (bevent->type == GDK_BUTTON_PRESS && bevent->button == 1) { gint width; gdk_pointer_grab (widget->window, FALSE, GDK_BUTTON_RELEASE_MASK | GDK_BUTTON1_MOTION_MASK, NULL, NULL, bevent->time); width = widget->allocation.width - 2 * view->border_width; view->start = CLAMP ((((bevent->x - view->border_width) * 256) / width), 0, 255); view->end = view->start; gtk_widget_queue_draw (widget); } return TRUE; }
static gboolean gimp_histogram_view_button_release (GtkWidget *widget, GdkEventButton *bevent) { GimpHistogramView *view = GIMP_HISTOGRAM_VIEW (widget); if (bevent->button == 1) { gint start, end; gdk_display_pointer_ungrab (gtk_widget_get_display (GTK_WIDGET (view)), bevent->time); start = view->start; end = view->end; view->start = MIN (start, end); view->end = MAX (start, end); g_signal_emit (view, histogram_view_signals[RANGE_CHANGED], 0, view->start, view->end); } return TRUE; }
static void gimp_histogram_view_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { GimpHistogramView *view = GIMP_HISTOGRAM_VIEW (object); switch (property_id) { case PROP_CHANNEL: g_value_set_enum (value, view->channel); break; case PROP_SCALE: g_value_set_enum (value, view->scale); break; case PROP_BORDER_WIDTH: g_value_set_int (value, view->border_width); break; case PROP_SUBDIVISIONS: g_value_set_int (value, view->subdivisions); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } }
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 void gimp_histogram_view_size_request (GtkWidget *widget, GtkRequisition *requisition) { GimpHistogramView *view = GIMP_HISTOGRAM_VIEW (widget); requisition->width = MIN_WIDTH + 2 * view->border_width; requisition->height = MIN_HEIGHT + 2 * view->border_width; }
static gboolean gimp_levels_tool_initialize (GimpTool *tool, GimpDisplay *display, GError **error) { GimpLevelsTool *l_tool = GIMP_LEVELS_TOOL (tool); GimpDrawable *drawable = gimp_image_get_active_drawable (display->image); if (! drawable) return FALSE; if (gimp_drawable_is_indexed (drawable)) { g_set_error (error, 0, 0, _("Levels does not operate on indexed layers.")); return FALSE; } if (! l_tool->hist) l_tool->hist = gimp_histogram_new (); levels_init (l_tool->levels); l_tool->channel = GIMP_HISTOGRAM_VALUE; l_tool->color = gimp_drawable_is_rgb (drawable); l_tool->alpha = gimp_drawable_has_alpha (drawable); if (l_tool->active_picker) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (l_tool->active_picker), FALSE); GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error); gimp_int_combo_box_set_sensitivity (GIMP_INT_COMBO_BOX (l_tool->channel_menu), levels_menu_sensitivity, l_tool, NULL); gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (l_tool->channel_menu), l_tool->channel); /* FIXME: hack */ if (! l_tool->color) l_tool->channel = (l_tool->channel == GIMP_HISTOGRAM_ALPHA) ? 1 : 0; levels_update (l_tool, ALL); gimp_drawable_calculate_histogram (drawable, l_tool->hist); gimp_histogram_view_set_histogram (GIMP_HISTOGRAM_VIEW (l_tool->hist_view), l_tool->hist); return TRUE; }
static gboolean gimp_histogram_view_motion_notify (GtkWidget *widget, GdkEventMotion *mevent) { GimpHistogramView *view = GIMP_HISTOGRAM_VIEW (widget); gint width; width = widget->allocation.width - 2 * view->border_width; view->start = CLAMP ((((mevent->x - view->border_width) * 256) / width), 0, 255); gtk_widget_queue_draw (widget); return TRUE; }
static void levels_channel_callback (GtkWidget *widget, GimpLevelsTool *tool) { gint value; if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value)) { tool->channel = value; gimp_histogram_view_set_channel (GIMP_HISTOGRAM_VIEW (tool->hist_view), tool->channel); /* FIXME: hack */ if (! tool->color) tool->channel = (tool->channel == GIMP_HISTOGRAM_ALPHA) ? 1 : 0; levels_update (tool, ALL); } }
static void gimp_histogram_view_finalize (GObject *object) { GimpHistogramView *view = GIMP_HISTOGRAM_VIEW (object); if (view->histogram) { gimp_histogram_unref (view->histogram); view->histogram = NULL; } if (view->bg_histogram) { gimp_histogram_unref (view->bg_histogram); view->bg_histogram = NULL; } G_OBJECT_CLASS (parent_class)->finalize (object); }
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_precision (drawable) == GIMP_PRECISION_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.0, 1.0); gimp_curve_view_set_range_y (GIMP_CURVE_VIEW (c_tool->graph), 0.0, 1.0); } return TRUE; }
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); if (! drawable) return FALSE; if (gimp_drawable_is_indexed (drawable)) { g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED, _("Levels does not operate on indexed layers.")); return FALSE; } gimp_config_reset (GIMP_CONFIG (l_tool->config)); if (l_tool->active_picker) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (l_tool->active_picker), FALSE); 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); return TRUE; }
static gboolean gimp_curves_tool_initialize (GimpTool *tool, GimpDisplay *display, GError **error) { GimpCurvesTool *c_tool = GIMP_CURVES_TOOL (tool); GimpDrawable *drawable = gimp_image_get_active_drawable (display->image); GimpHistogram *histogram; if (! drawable) return FALSE; if (gimp_drawable_is_indexed (drawable)) { g_set_error (error, 0, 0, _("Curves does not operate on indexed layers.")); return FALSE; } gimp_config_reset (GIMP_CONFIG (c_tool->config)); GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error); /* 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 (); gimp_drawable_calculate_histogram (drawable, histogram); gimp_histogram_view_set_background (GIMP_HISTOGRAM_VIEW (c_tool->graph), histogram); gimp_histogram_unref (histogram); return TRUE; }
static void gimp_histogram_box_init (GimpHistogramBox *box) { GtkWidget *hbox; GtkWidget *vbox; GtkWidget *spinbutton; GtkObject *adjustment; GtkWidget *frame; GtkWidget *view; GtkWidget *bar; GtkWidget *slider_area; gtk_box_set_spacing (GTK_BOX (box), 2); /* The histogram */ frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_box_pack_start (GTK_BOX (box), frame, TRUE, TRUE, 0); gtk_widget_show (frame); view = gimp_histogram_view_new (TRUE); gtk_container_add (GTK_CONTAINER (frame), view); gtk_widget_show (view); g_signal_connect (view, "range-changed", G_CALLBACK (gimp_histogram_box_histogram_range), box); box->view = GIMP_HISTOGRAM_VIEW (view); /* The gradient below the histogram */ frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 0); gtk_widget_show (frame); box->slider_area = slider_area = gtk_event_box_new (); gtk_widget_set_size_request (slider_area, -1, GRADIENT_HEIGHT + CONTROL_HEIGHT); gtk_widget_add_events (slider_area, HISTOGRAM_EVENT_MASK); gtk_container_add (GTK_CONTAINER (frame), slider_area); gtk_widget_show (slider_area); g_signal_connect (slider_area, "event", G_CALLBACK (gimp_histogram_slider_area_event), box); g_signal_connect_after (slider_area, "expose-event", G_CALLBACK (gimp_histogram_slider_area_expose), box); vbox = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (slider_area), vbox); gtk_widget_show (vbox); bar = g_object_new (GIMP_TYPE_COLOR_BAR, "histogram-channel", box->view->channel, "xpad", box->view->border_width, "ypad", box->view->border_width, NULL); gtk_widget_set_size_request (bar, -1, GRADIENT_HEIGHT + 2 * box->view->border_width); gtk_box_pack_start (GTK_BOX (vbox), bar, FALSE, FALSE, 0); gtk_widget_show (bar); g_signal_connect (view, "notify::histogram-channel", G_CALLBACK (gimp_histogram_box_channel_notify), bar); g_signal_connect (view, "notify::border-width", G_CALLBACK (gimp_histogram_box_border_notify), bar); /* The range selection */ hbox = gtk_hbox_new (FALSE, 6); gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); /* low spinbutton */ spinbutton = gimp_spin_button_new (&adjustment, 0.0, 0.0, 255.0, 1.0, 16.0, 0.0, 1.0, 0); box->low_adj = GTK_ADJUSTMENT (adjustment); gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0); gtk_widget_show (spinbutton); g_signal_connect (adjustment, "value-changed", G_CALLBACK (gimp_histogram_box_low_adj_update), box); /* high spinbutton */ spinbutton = gimp_spin_button_new (&adjustment, 255.0, 0.0, 255.0, 1.0, 16.0, 0.0, 1.0, 0); box->high_adj = GTK_ADJUSTMENT (adjustment); gtk_box_pack_end (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0); gtk_widget_show (spinbutton); g_signal_connect (adjustment, "value-changed", G_CALLBACK (gimp_histogram_box_high_adj_update), box); #ifdef DEBUG_VIEW spinbutton = gimp_prop_spin_button_new (G_OBJECT (box->view), "border-width", 1, 5, 0); gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0); gtk_widget_show (spinbutton); spinbutton = gimp_prop_spin_button_new (G_OBJECT (box->view), "subdivisions", 1, 5, 0); gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0); gtk_widget_show (spinbutton); #endif }
static void gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool) { GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool); GimpToolOptions *tool_options = GIMP_TOOL_GET_OPTIONS (image_map_tool); GimpCurvesConfig *config = tool->config; GtkListStore *store; GtkSizeGroup *label_group; GtkWidget *main_vbox; GtkWidget *vbox; GtkWidget *hbox; GtkWidget *hbox2; GtkWidget *label; GtkWidget *frame; GtkWidget *table; GtkWidget *button; GtkWidget *bar; GtkWidget *combo; g_signal_connect (image_map_tool->settings_box, "file-dialog-setup", G_CALLBACK (gimp_curves_tool_export_setup), image_map_tool); main_vbox = gimp_image_map_tool_dialog_get_vbox (image_map_tool); label_group = gimp_image_map_tool_dialog_get_label_group (image_map_tool); /* The combo box for selecting channels */ hbox = gtk_hbox_new (FALSE, 6); gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); label = gtk_label_new_with_mnemonic (_("Cha_nnel:")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); gtk_size_group_add_widget (label_group, label); store = gimp_enum_store_new_with_range (GIMP_TYPE_HISTOGRAM_CHANNEL, GIMP_HISTOGRAM_VALUE, GIMP_HISTOGRAM_ALPHA); tool->channel_menu = gimp_enum_combo_box_new_with_model (GIMP_ENUM_STORE (store)); g_object_unref (store); gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (tool->channel_menu), config->channel); gimp_enum_combo_box_set_stock_prefix (GIMP_ENUM_COMBO_BOX (tool->channel_menu), "gimp-channel"); gtk_box_pack_start (GTK_BOX (hbox), tool->channel_menu, FALSE, FALSE, 0); gtk_widget_show (tool->channel_menu); g_signal_connect (tool->channel_menu, "changed", G_CALLBACK (curves_channel_callback), tool); gtk_label_set_mnemonic_widget (GTK_LABEL (label), tool->channel_menu); button = gtk_button_new_with_mnemonic (_("R_eset Channel")); gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); gtk_widget_show (button); g_signal_connect (button, "clicked", G_CALLBACK (curves_channel_reset_callback), tool); /* The histogram scale radio buttons */ hbox2 = gimp_prop_enum_stock_box_new (G_OBJECT (tool_options), "histogram-scale", "gimp-histogram", 0, 0); gtk_box_pack_end (GTK_BOX (hbox), hbox2, FALSE, FALSE, 0); gtk_widget_show (hbox2); /* The table for the color bars and the graph */ table = gtk_table_new (2, 2, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 2); gtk_table_set_row_spacings (GTK_TABLE (table), 2); gtk_box_pack_start (GTK_BOX (main_vbox), table, TRUE, TRUE, 0); /* The left color bar */ vbox = gtk_vbox_new (FALSE, 0); gtk_table_attach (GTK_TABLE (table), vbox, 0, 1, 0, 1, GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_widget_show (vbox); frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, RADIUS); gtk_widget_show (frame); tool->yrange = gimp_color_bar_new (GTK_ORIENTATION_VERTICAL); gtk_widget_set_size_request (tool->yrange, BAR_SIZE, -1); gtk_container_add (GTK_CONTAINER (frame), tool->yrange); gtk_widget_show (tool->yrange); /* The curves graph */ frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_table_attach (GTK_TABLE (table), frame, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_widget_show (frame); tool->graph = gimp_curve_view_new (); gtk_widget_set_size_request (tool->graph, GRAPH_SIZE + RADIUS * 2, GRAPH_SIZE + RADIUS * 2); g_object_set (tool->graph, "border-width", RADIUS, "subdivisions", 1, NULL); gimp_curve_view_set_curve (GIMP_CURVE_VIEW (tool->graph), config->curve[config->channel]); gtk_container_add (GTK_CONTAINER (frame), tool->graph); gtk_widget_show (tool->graph); gimp_histogram_options_connect_view (GIMP_HISTOGRAM_OPTIONS (tool_options), GIMP_HISTOGRAM_VIEW (tool->graph)); /* The bottom color bar */ hbox2 = gtk_hbox_new (FALSE, 0); gtk_table_attach (GTK_TABLE (table), hbox2, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (hbox2); frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_box_pack_start (GTK_BOX (hbox2), frame, TRUE, TRUE, RADIUS); gtk_widget_show (frame); vbox = gtk_vbox_new (TRUE, 0); gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_widget_show (vbox); tool->xrange = gimp_color_bar_new (GTK_ORIENTATION_HORIZONTAL); gtk_widget_set_size_request (tool->xrange, -1, BAR_SIZE / 2); gtk_box_pack_start (GTK_BOX (vbox), tool->xrange, TRUE, TRUE, 0); gtk_widget_show (tool->xrange); bar = gimp_color_bar_new (GTK_ORIENTATION_HORIZONTAL); gtk_box_pack_start (GTK_BOX (vbox), bar, TRUE, TRUE, 0); gtk_widget_show (bar); gtk_widget_show (table); hbox = gtk_hbox_new (FALSE, 6); gtk_box_pack_end (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); label = gtk_label_new_with_mnemonic (_("Curve _type:")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); tool->curve_type = combo = gimp_enum_combo_box_new (GIMP_TYPE_CURVE_TYPE); gimp_enum_combo_box_set_stock_prefix (GIMP_ENUM_COMBO_BOX (combo), "gimp-curve"); gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), 0, G_CALLBACK (curves_curve_type_callback), tool); gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0); gtk_widget_show (combo); gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo); }
static gboolean gimp_histogram_view_expose (GtkWidget *widget, GdkEventExpose *event) { GimpHistogramView *view = GIMP_HISTOGRAM_VIEW (widget); GtkStyle *style = gtk_widget_get_style (widget); gint x; gint x1, x2; gint border; gint width, height; gdouble max = 0.0; gdouble bg_max = 0.0; gint xstop; GdkGC *gc_in; GdkGC *gc_out; GdkGC *bg_gc_in; GdkGC *bg_gc_out; GdkGC *rgb_gc[3] = { NULL, NULL, NULL }; if (! view->histogram && ! view->bg_histogram) return FALSE; border = view->border_width; width = widget->allocation.width - 2 * border; height = widget->allocation.height - 2 * border; x1 = CLAMP (MIN (view->start, view->end), 0, 255); x2 = CLAMP (MAX (view->start, view->end), 0, 255); gdk_draw_rectangle (widget->window, style->base_gc[GTK_STATE_NORMAL], TRUE, 0, 0, widget->allocation.width, widget->allocation.height); /* Draw the outer border */ gdk_draw_rectangle (widget->window, style->dark_gc[GTK_STATE_NORMAL], FALSE, border, border, width - 1, height - 1); if (view->histogram) max = gimp_histogram_view_get_maximum (view, view->histogram, view->channel); if (view->bg_histogram) bg_max = gimp_histogram_view_get_maximum (view, view->bg_histogram, view->channel); gc_in = style->text_gc[GTK_STATE_SELECTED]; gc_out = style->text_gc[GTK_STATE_NORMAL]; bg_gc_in = style->mid_gc[GTK_STATE_SELECTED]; bg_gc_out = style->mid_gc[GTK_STATE_NORMAL]; if (view->channel == GIMP_HISTOGRAM_RGB) { GdkGCValues values; GdkColor color; values.function = GDK_OR; for (x = 0; x < 3; x++) { rgb_gc[x] = gdk_gc_new_with_values (widget->window, &values, GDK_GC_FUNCTION); color.red = (x == 0 ? 0xFFFF : 0x0); color.green = (x == 1 ? 0xFFFF : 0x0); color.blue = (x == 2 ? 0xFFFF : 0x0); gdk_gc_set_rgb_fg_color (rgb_gc[x], &color); } } xstop = 1; for (x = 0; x < width; x++) { gboolean in_selection = FALSE; gint i = (x * 256) / width; gint j = ((x + 1) * 256) / width; if (! (x1 == 0 && x2 == 255)) { gint k = i; do in_selection |= (x1 <= k && k <= x2); while (++k < j); } if (view->subdivisions > 1 && x >= (xstop * width / view->subdivisions)) { gdk_draw_line (widget->window, style->dark_gc[GTK_STATE_NORMAL], x + border, border, x + border, border + height - 1); xstop++; } else if (in_selection) { gdk_draw_line (widget->window, style->base_gc[GTK_STATE_SELECTED], x + border, border, x + border, border + height - 1); } if (view->channel == GIMP_HISTOGRAM_RGB) { gint c; for (c = 0; c < 3; c++) gimp_histogram_view_draw_spike (view, GIMP_HISTOGRAM_RED + c, style->black_gc, NULL, x, i, j, max, bg_max, height, border); for (c = 0; c < 3; c++) gimp_histogram_view_draw_spike (view, GIMP_HISTOGRAM_RED + c, rgb_gc[c], NULL, x, i, j, max, bg_max, height, border); gimp_histogram_view_draw_spike (view, view->channel, in_selection ? gc_in : gc_out, NULL, x, i, j, max, bg_max, height, border); } else { gimp_histogram_view_draw_spike (view, view->channel, in_selection ? gc_in : gc_out, in_selection ? bg_gc_in : bg_gc_out, x, i, j, max, bg_max, height, border); } } if (view->channel == GIMP_HISTOGRAM_RGB) { for (x = 0; x < 3; x++) g_object_unref (rgb_gc[x]); } return FALSE; }
static void gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool) { GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool); GimpToolOptions *tool_options = GIMP_TOOL_GET_OPTIONS (image_map_tool); GimpLevelsConfig *config = tool->config; GtkListStore *store; GtkSizeGroup *label_group; GtkWidget *main_vbox; GtkWidget *vbox; GtkWidget *vbox2; GtkWidget *vbox3; GtkWidget *hbox; GtkWidget *hbox2; GtkWidget *label; GtkWidget *menu; GtkWidget *frame; GtkWidget *hbbox; GtkWidget *button; GtkWidget *spinbutton; GtkAdjustment *adjustment; GtkWidget *bar; GtkWidget *handle_bar; gint border; g_signal_connect (image_map_tool->settings_box, "file-dialog-setup", G_CALLBACK (gimp_levels_tool_export_setup), image_map_tool); main_vbox = gimp_image_map_tool_dialog_get_vbox (image_map_tool); label_group = gimp_image_map_tool_dialog_get_label_group (image_map_tool); /* The option menu for selecting channels */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); label = gtk_label_new_with_mnemonic (_("Cha_nnel:")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); gtk_size_group_add_widget (label_group, label); store = gimp_enum_store_new_with_range (GIMP_TYPE_HISTOGRAM_CHANNEL, GIMP_HISTOGRAM_VALUE, GIMP_HISTOGRAM_ALPHA); menu = gimp_enum_combo_box_new_with_model (GIMP_ENUM_STORE (store)); g_object_unref (store); g_signal_connect (menu, "changed", G_CALLBACK (levels_channel_callback), tool); gimp_enum_combo_box_set_stock_prefix (GIMP_ENUM_COMBO_BOX (menu), "gimp-channel"); gtk_box_pack_start (GTK_BOX (hbox), menu, FALSE, FALSE, 0); gtk_widget_show (menu); tool->channel_menu = menu; gtk_label_set_mnemonic_widget (GTK_LABEL (label), menu); button = gtk_button_new_with_mnemonic (_("R_eset Channel")); gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); gtk_widget_show (button); g_signal_connect (button, "clicked", G_CALLBACK (levels_channel_reset_callback), tool); menu = gimp_prop_enum_stock_box_new (G_OBJECT (tool_options), "histogram-scale", "gimp-histogram", 0, 0); gtk_box_pack_end (GTK_BOX (hbox), menu, FALSE, FALSE, 0); gtk_widget_show (menu); /* Input levels frame */ frame = gimp_frame_new (_("Input Levels")); gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 0); gtk_widget_show (frame); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_widget_show (vbox); frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0); gtk_widget_show (frame); vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_add (GTK_CONTAINER (frame), vbox2); gtk_widget_show (vbox2); tool->histogram_view = gimp_histogram_view_new (FALSE); gtk_box_pack_start (GTK_BOX (vbox2), tool->histogram_view, TRUE, TRUE, 0); gtk_widget_show (GTK_WIDGET (tool->histogram_view)); gimp_histogram_options_connect_view (GIMP_HISTOGRAM_OPTIONS (tool_options), GIMP_HISTOGRAM_VIEW (tool->histogram_view)); g_object_get (tool->histogram_view, "border-width", &border, NULL); vbox3 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_set_border_width (GTK_CONTAINER (vbox3), border); gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0); gtk_widget_show (vbox3); tool->input_bar = g_object_new (GIMP_TYPE_COLOR_BAR, NULL); gtk_widget_set_size_request (tool->input_bar, -1, GRADIENT_HEIGHT / 2); gtk_box_pack_start (GTK_BOX (vbox3), tool->input_bar, FALSE, FALSE, 0); gtk_widget_show (tool->input_bar); bar = g_object_new (GIMP_TYPE_COLOR_BAR, NULL); gtk_widget_set_size_request (bar, -1, GRADIENT_HEIGHT / 2); gtk_box_pack_start (GTK_BOX (vbox3), bar, FALSE, FALSE, 0); gtk_widget_show (bar); handle_bar = g_object_new (GIMP_TYPE_HANDLE_BAR, NULL); gtk_widget_set_size_request (handle_bar, -1, CONTROL_HEIGHT); gtk_box_pack_start (GTK_BOX (vbox3), handle_bar, FALSE, FALSE, 0); gtk_widget_show (handle_bar); gimp_handle_bar_connect_events (GIMP_HANDLE_BAR (handle_bar), tool->input_bar); gimp_handle_bar_connect_events (GIMP_HANDLE_BAR (handle_bar), bar); /* Horizontal box for input levels spinbuttons */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); /* low input spin */ hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (GTK_BOX (hbox), hbox2, FALSE, FALSE, 0); gtk_widget_show (hbox2); button = gimp_levels_tool_color_picker_new (tool, PICK_LOW_INPUT); gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, FALSE, 0); gtk_widget_show (button); tool->low_input_spinbutton = spinbutton = gimp_prop_spin_button_new (image_map_tool->config, "low-input", 0.01, 0.1, 1); gtk_box_pack_start (GTK_BOX (hbox2), spinbutton, FALSE, FALSE, 0); gtk_widget_show (spinbutton); tool->low_input = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spinbutton)); gimp_handle_bar_set_adjustment (GIMP_HANDLE_BAR (handle_bar), 0, tool->low_input); /* input gamma spin */ spinbutton = gimp_prop_spin_button_new (image_map_tool->config, "gamma", 0.01, 0.1, 2); gtk_box_pack_start (GTK_BOX (hbox), spinbutton, TRUE, FALSE, 0); gimp_help_set_help_data (spinbutton, _("Gamma"), NULL); gtk_widget_show (spinbutton); tool->gamma = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spinbutton)); tool->gamma_linear = GTK_ADJUSTMENT (gtk_adjustment_new (127, 0, 255, 0.1, 1.0, 0.0)); g_signal_connect (tool->gamma_linear, "value-changed", G_CALLBACK (levels_linear_gamma_changed), tool); gimp_handle_bar_set_adjustment (GIMP_HANDLE_BAR (handle_bar), 1, tool->gamma_linear); g_object_unref (tool->gamma_linear); /* high input spin */ hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_end (GTK_BOX (hbox), hbox2, FALSE, FALSE, 0); gtk_widget_show (hbox2); button = gimp_levels_tool_color_picker_new (tool, PICK_HIGH_INPUT); gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, FALSE, 0); gtk_widget_show (button); spinbutton = gimp_prop_spin_button_new (image_map_tool->config, "high-input", 0.01, 0.1, 1); gtk_box_pack_start (GTK_BOX (hbox2), spinbutton, FALSE, FALSE, 0); gtk_widget_show (spinbutton); tool->high_input_spinbutton = spinbutton; tool->high_input = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spinbutton)); gimp_handle_bar_set_adjustment (GIMP_HANDLE_BAR (handle_bar), 2, tool->high_input); /* Output levels frame */ frame = gimp_frame_new (_("Output Levels")); gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4); gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_widget_show (vbox); frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_set_border_width (GTK_CONTAINER (vbox2), border); gtk_container_add (GTK_CONTAINER (frame), vbox2); gtk_widget_show (vbox2); tool->output_bar = g_object_new (GIMP_TYPE_COLOR_BAR, NULL); gtk_widget_set_size_request (tool->output_bar, -1, GRADIENT_HEIGHT); gtk_box_pack_start (GTK_BOX (vbox2), tool->output_bar, FALSE, FALSE, 0); gtk_widget_show (tool->output_bar); handle_bar = g_object_new (GIMP_TYPE_HANDLE_BAR, NULL); gtk_widget_set_size_request (handle_bar, -1, CONTROL_HEIGHT); gtk_box_pack_start (GTK_BOX (vbox2), handle_bar, FALSE, FALSE, 0); gtk_widget_show (handle_bar); gimp_handle_bar_connect_events (GIMP_HANDLE_BAR (handle_bar), tool->output_bar); /* Horizontal box for levels spin widgets */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); /* low output spin */ tool->low_output_spinbutton = spinbutton = gimp_prop_spin_button_new (image_map_tool->config, "low-output", 0.01, 0.1, 1); gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0); gtk_widget_show (spinbutton); adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spinbutton)); gimp_handle_bar_set_adjustment (GIMP_HANDLE_BAR (handle_bar), 0, adjustment); /* high output spin */ tool->high_output_spinbutton = spinbutton = gimp_prop_spin_button_new (image_map_tool->config, "high-output", 0.01, 0.1, 1); gtk_box_pack_end (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0); gtk_widget_show (spinbutton); adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spinbutton)); gimp_handle_bar_set_adjustment (GIMP_HANDLE_BAR (handle_bar), 2, adjustment); /* all channels frame */ frame = gimp_frame_new (_("All Channels")); gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_container_add (GTK_CONTAINER (frame), hbox); gtk_widget_show (hbox); hbbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_box_pack_end (GTK_BOX (hbox), hbbox, FALSE, FALSE, 0); gtk_widget_show (hbbox); button = gtk_button_new_with_mnemonic (_("_Auto")); gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0); gimp_help_set_help_data (button, _("Adjust levels automatically"), NULL); gtk_widget_show (button); g_signal_connect (button, "clicked", G_CALLBACK (levels_stretch_callback), tool); button = gimp_levels_tool_color_picker_new (tool, PICK_LOW_INPUT | PICK_ALL_CHANNELS); gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0); gtk_widget_show (button); button = gimp_levels_tool_color_picker_new (tool, PICK_GAMMA | PICK_ALL_CHANNELS); gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0); gtk_widget_show (button); button = gimp_levels_tool_color_picker_new (tool, PICK_HIGH_INPUT | PICK_ALL_CHANNELS); gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0); gtk_widget_show (button); button = gimp_stock_button_new (GIMP_STOCK_TOOL_CURVES, _("Edit these Settings as Curves")); gtk_box_pack_start (GTK_BOX (main_vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); g_signal_connect (button, "clicked", G_CALLBACK (levels_to_curves_callback), tool); gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (tool->channel_menu), config->channel); }
static void gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool) { GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool); GimpToolOptions *tool_options = GIMP_TOOL_GET_OPTIONS (image_map_tool); GtkListStore *store; GtkWidget *vbox; GtkWidget *vbox2; GtkWidget *vbox3; GtkWidget *hbox; GtkWidget *hbox2; GtkWidget *label; GtkWidget *menu; GtkWidget *frame; GtkWidget *hbbox; GtkWidget *button; GtkWidget *spinbutton; GtkWidget *bar; GtkObject *data; gint border; vbox = image_map_tool->main_vbox; /* The option menu for selecting channels */ hbox = gtk_hbox_new (FALSE, 6); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); label = gtk_label_new_with_mnemonic (_("Cha_nnel:")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); store = gimp_enum_store_new_with_range (GIMP_TYPE_HISTOGRAM_CHANNEL, GIMP_HISTOGRAM_VALUE, GIMP_HISTOGRAM_ALPHA); menu = gimp_enum_combo_box_new_with_model (GIMP_ENUM_STORE (store)); g_object_unref (store); g_signal_connect (menu, "changed", G_CALLBACK (levels_channel_callback), tool); gimp_enum_combo_box_set_stock_prefix (GIMP_ENUM_COMBO_BOX (menu), "gimp-channel"); gtk_box_pack_start (GTK_BOX (hbox), menu, FALSE, FALSE, 0); gtk_widget_show (menu); tool->channel_menu = menu; gtk_label_set_mnemonic_widget (GTK_LABEL (label), menu); button = gtk_button_new_with_mnemonic (_("R_eset Channel")); gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); gtk_widget_show (button); g_signal_connect (button, "clicked", G_CALLBACK (levels_channel_reset_callback), tool); menu = gimp_prop_enum_stock_box_new (G_OBJECT (tool_options), "histogram-scale", "gimp-histogram", 0, 0); gtk_box_pack_end (GTK_BOX (hbox), menu, FALSE, FALSE, 0); gtk_widget_show (menu); /* Input levels frame */ frame = gimp_frame_new (_("Input Levels")); gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0); gtk_widget_show (frame); vbox2 = gtk_vbox_new (FALSE, 2); gtk_container_add (GTK_CONTAINER (frame), vbox2); gtk_widget_show (vbox2); frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_box_pack_start (GTK_BOX (vbox2), frame, TRUE, TRUE, 0); gtk_widget_show (frame); tool->hist_view = gimp_histogram_view_new (FALSE); gtk_container_add (GTK_CONTAINER (frame), tool->hist_view); gtk_widget_show (GTK_WIDGET (tool->hist_view)); gimp_histogram_options_connect_view (GIMP_HISTOGRAM_OPTIONS (tool_options), GIMP_HISTOGRAM_VIEW (tool->hist_view)); g_object_get (tool->hist_view, "border-width", &border, NULL); frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_box_pack_start (GTK_BOX (vbox2), frame, FALSE, FALSE, 0); gtk_widget_show (frame); tool->input_area = gtk_event_box_new (); gtk_widget_set_size_request (tool->input_area, -1, GRADIENT_HEIGHT + CONTROL_HEIGHT); gtk_widget_add_events (tool->input_area, LEVELS_EVENT_MASK); gtk_container_add (GTK_CONTAINER (frame), tool->input_area); gtk_widget_show (tool->input_area); g_signal_connect (tool->input_area, "event", G_CALLBACK (levels_input_area_event), tool); g_signal_connect_after (tool->input_area, "expose-event", G_CALLBACK (levels_input_area_expose), tool); vbox3 = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (tool->input_area), vbox3); gtk_widget_show (vbox3); tool->input_bar = g_object_new (GIMP_TYPE_COLOR_BAR, "xpad", border, "ypad", 0, NULL); gtk_widget_set_size_request (tool->input_bar, -1, GRADIENT_HEIGHT / 2); gtk_box_pack_start (GTK_BOX (vbox3), tool->input_bar, FALSE, FALSE, 0); gtk_widget_show (tool->input_bar); bar = g_object_new (GIMP_TYPE_COLOR_BAR, "xpad", border, "ypad", 0, NULL); gtk_widget_set_size_request (bar, -1, GRADIENT_HEIGHT / 2); gtk_box_pack_start (GTK_BOX (vbox3), bar, FALSE, FALSE, 0); gtk_widget_show (bar); /* Horizontal box for input levels spinbuttons */ hbox = gtk_hbox_new (FALSE, 6); gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); /* low input spin */ hbox2 = gtk_hbox_new (FALSE, 2); gtk_box_pack_start (GTK_BOX (hbox), hbox2, FALSE, FALSE, 0); gtk_widget_show (hbox2); button = gimp_levels_tool_color_picker_new (tool, LOW_INPUT); gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, FALSE, 0); gtk_widget_show (button); spinbutton = gimp_spin_button_new (&data, 0, 0, 255, 1, 10, 10, 0.5, 0); gtk_box_pack_start (GTK_BOX (hbox2), spinbutton, FALSE, FALSE, 0); gtk_widget_show (spinbutton); tool->low_input = GTK_ADJUSTMENT (data); g_signal_connect (tool->low_input, "value-changed", G_CALLBACK (levels_low_input_adjustment_update), tool); /* input gamma spin */ spinbutton = gimp_spin_button_new (&data, 1, 0.1, 10, 0.01, 0.1, 1, 0.5, 2); gtk_box_pack_start (GTK_BOX (hbox), spinbutton, TRUE, FALSE, 0); gimp_help_set_help_data (spinbutton, _("Gamma"), NULL); gtk_widget_show (spinbutton); tool->gamma = GTK_ADJUSTMENT (data); g_signal_connect (tool->gamma, "value-changed", G_CALLBACK (levels_gamma_adjustment_update), tool); /* high input spin */ hbox2 = gtk_hbox_new (FALSE, 2); gtk_box_pack_end (GTK_BOX (hbox), hbox2, FALSE, FALSE, 0); gtk_widget_show (hbox2); button = gimp_levels_tool_color_picker_new (tool, HIGH_INPUT); gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, FALSE, 0); gtk_widget_show (button); spinbutton = gimp_spin_button_new (&data, 255, 0, 255, 1, 10, 10, 0.5, 0); gtk_box_pack_start (GTK_BOX (hbox2), spinbutton, FALSE, FALSE, 0); gtk_widget_show (spinbutton); tool->high_input = GTK_ADJUSTMENT (data); g_signal_connect (tool->high_input, "value-changed", G_CALLBACK (levels_high_input_adjustment_update), tool); /* Output levels frame */ frame = gimp_frame_new (_("Output Levels")); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); vbox2 = gtk_vbox_new (FALSE, 4); gtk_container_add (GTK_CONTAINER (frame), vbox2); gtk_widget_show (vbox2); frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_box_pack_start (GTK_BOX (vbox2), frame, FALSE, FALSE, 0); gtk_widget_show (frame); tool->output_area = gtk_event_box_new (); gtk_widget_set_size_request (tool->output_area, -1, GRADIENT_HEIGHT + CONTROL_HEIGHT); gtk_widget_add_events (bar, LEVELS_EVENT_MASK); gtk_container_add (GTK_CONTAINER (frame), tool->output_area); gtk_widget_show (tool->output_area); g_signal_connect (tool->output_area, "event", G_CALLBACK (levels_output_area_event), tool); g_signal_connect_after (tool->output_area, "expose-event", G_CALLBACK (levels_output_area_expose), tool); vbox3 = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (tool->output_area), vbox3); gtk_widget_show (vbox3); tool->output_bar = g_object_new (GIMP_TYPE_COLOR_BAR, "xpad", border, "ypad", 0, NULL); gtk_widget_set_size_request (tool->output_bar, -1, GRADIENT_HEIGHT); gtk_box_pack_start (GTK_BOX (vbox3), tool->output_bar, FALSE, FALSE, 0); gtk_widget_show (tool->output_bar); /* Horizontal box for levels spin widgets */ hbox = gtk_hbox_new (FALSE, 6); gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); /* low output spin */ spinbutton = gimp_spin_button_new (&data, 0, 0, 255, 1, 10, 10, 0.5, 0); gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0); gtk_widget_show (spinbutton); tool->low_output = GTK_ADJUSTMENT (data); g_signal_connect (tool->low_output, "value-changed", G_CALLBACK (levels_low_output_adjustment_update), tool); /* high output spin */ spinbutton = gimp_spin_button_new (&data, 255, 0, 255, 1, 10, 10, 0.5, 0); gtk_box_pack_end (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0); gtk_widget_show (spinbutton); tool->high_output = GTK_ADJUSTMENT (data); g_signal_connect (tool->high_output, "value-changed", G_CALLBACK (levels_high_output_adjustment_update), tool); frame = gimp_frame_new (_("All Channels")); gtk_box_pack_end (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); hbox = gtk_hbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (frame), hbox); gtk_widget_show (hbox); hbbox = gtk_hbutton_box_new (); gtk_box_set_spacing (GTK_BOX (hbbox), 4); gtk_box_pack_start (GTK_BOX (hbox), hbbox, FALSE, FALSE, 0); gtk_widget_show (hbbox); gtk_box_pack_start (GTK_BOX (hbbox), image_map_tool->load_button, FALSE, FALSE, 0); gtk_widget_show (image_map_tool->load_button); gtk_box_pack_start (GTK_BOX (hbbox), image_map_tool->save_button, FALSE, FALSE, 0); gtk_widget_show (image_map_tool->save_button); hbbox = gtk_hbox_new (FALSE, 6); gtk_box_pack_end (GTK_BOX (hbox), hbbox, FALSE, FALSE, 0); gtk_widget_show (hbbox); button = gtk_button_new_with_mnemonic (_("_Auto")); gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0); gimp_help_set_help_data (button, _("Adjust levels automatically"), NULL); gtk_widget_show (button); g_signal_connect (button, "clicked", G_CALLBACK (levels_stretch_callback), tool); button = gimp_levels_tool_color_picker_new (tool, LOW_INPUT | ALL_CHANNELS); gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0); gtk_widget_show (button); button = gimp_levels_tool_color_picker_new (tool, GAMMA | ALL_CHANNELS); gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0); gtk_widget_show (button); button = gimp_levels_tool_color_picker_new (tool, HIGH_INPUT | ALL_CHANNELS); gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0); gtk_widget_show (button); g_signal_connect (image_map_tool->shell, "unmap", G_CALLBACK (gimp_levels_tool_dialog_unmap), tool); }