added a tool icon and descriptive string to the dialog's title box. Create

2002-08-28  Michael Natterer  <mitch@gimp.org>

	* app/tools/gimpimagemaptool.[ch]: added a tool icon and
	descriptive string to the dialog's title box. Create the
	drawable preview with is_popup == TRUE so it doesn't show
	layers in the image context. Still not perfect...

	* app/tools/gimpbrightnesscontrasttool.c
	* app/tools/gimpcolorbalancetool.c
	* app/tools/gimpcurvestool.c
	* app/tools/gimphuesaturationtool.c
	* app/tools/gimplevelstool.c
	* app/tools/gimpposterizetool.c
	* app/tools/gimpthresholdtool.c: Chain up early in initialize()
	and return if gdisp == NULL. Set stock_id and desc_text so
	GimpImageMapTool can display them. Added lots of mnemonics
	(#80804). Use gimp_size_entry_new() instead of manually creating
	the slider+spinbutton stuff.

	* app/tools/gimpcurvestool.c
	* app/tools/gimphistogramtool.c
	* app/tools/gimplevelstool.c: changed widgets packing to make them
	resizable without strange effects. Put the "Load", "Save" and
	"Auto" buttons into a frame.

	* app/tools/gimphuesaturationtool.c: use GimpColorAreas instead of
	deprecated GtkPreviews. Arranged the color previews and their
	radio buttons as a color wheel. Not the best solution maybe but
	IMHO better than the old GUI.
This commit is contained in:
Michael Natterer 2002-08-28 19:47:07 +00:00 committed by Michael Natterer
parent 3f4d4d2118
commit 14e0d0737b
11 changed files with 367 additions and 352 deletions

View File

@ -1,3 +1,33 @@
2002-08-28 Michael Natterer <mitch@gimp.org>
* app/tools/gimpimagemaptool.[ch]: added a tool icon and
descriptive string to the dialog's title box. Create the
drawable preview with is_popup == TRUE so it doesn't show
layers in the image context. Still not perfect...
* app/tools/gimpbrightnesscontrasttool.c
* app/tools/gimpcolorbalancetool.c
* app/tools/gimpcurvestool.c
* app/tools/gimphuesaturationtool.c
* app/tools/gimplevelstool.c
* app/tools/gimpposterizetool.c
* app/tools/gimpthresholdtool.c: Chain up early in initialize()
and return if gdisp == NULL. Set stock_id and desc_text so
GimpImageMapTool can display them. Added lots of mnemonics
(#80804). Use gimp_size_entry_new() instead of manually creating
the slider+spinbutton stuff.
* app/tools/gimpcurvestool.c
* app/tools/gimphistogramtool.c
* app/tools/gimplevelstool.c: changed widgets packing to make them
resizable without strange effects. Put the "Load", "Save" and
"Auto" buttons into a frame.
* app/tools/gimphuesaturationtool.c: use GimpColorAreas instead of
deprecated GtkPreviews. Arranged the color previews and their
radio buttons as a color wheel. Not the best solution maybe but
IMHO better than the old GUI.
2002-08-28 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpdrawablepreview.c (gimp_drawable_preview_render):

View File

@ -147,6 +147,8 @@ gimp_brightness_contrast_tool_init (GimpBrightnessContrastTool *bc_tool)
image_map_tool->shell_title = _("Brightness-Contrast");
image_map_tool->shell_name = "brightness_contrast";
image_map_tool->shell_desc = _("Adjust Brightness and Contrast");
image_map_tool->stock_id = GIMP_STOCK_TOOL_BRIGHTNESS_CONTRAST;
bc_tool->brightness = 0.0;
bc_tool->contrast = 0.0;
@ -177,8 +179,13 @@ gimp_brightness_contrast_tool_initialize (GimpTool *tool,
bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (tool);
if (gdisp &&
gimp_drawable_is_indexed (gimp_image_active_drawable (gdisp->gimage)))
if (! gdisp)
{
GIMP_TOOL_CLASS (parent_class)->initialize (tool, gdisp);
return;
}
if (gimp_drawable_is_indexed (gimp_image_active_drawable (gdisp->gimage)))
{
g_message (_("Brightness-Contrast does not operate on indexed drawables."));
return;
@ -220,6 +227,7 @@ gimp_brightness_contrast_tool_dialog (GimpImageMapTool *image_map_tool)
{
GimpBrightnessContrastTool *bc_tool;
GtkWidget *table;
GtkWidget *slider;
GtkObject *data;
bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (image_map_tool);
@ -234,14 +242,15 @@ gimp_brightness_contrast_tool_dialog (GimpImageMapTool *image_map_tool)
/* Create the brightness scale widget */
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
_("Brightness:"),
_("_Brightness:"),
SLIDER_WIDTH, 75,
bc_tool->brightness,
-127.0, 127.0, 1.0, 10.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
bc_tool->brightness_data = GTK_ADJUSTMENT (data);
slider = GIMP_SCALE_ENTRY_SCALE (data);
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
g_signal_connect (G_OBJECT (data), "value_changed",
G_CALLBACK (brightness_contrast_brightness_adjustment_update),
@ -249,14 +258,15 @@ gimp_brightness_contrast_tool_dialog (GimpImageMapTool *image_map_tool)
/* Create the contrast scale widget */
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 1,
_("Contrast:"),
_("Con_trast:"),
SLIDER_WIDTH, 75,
bc_tool->contrast,
-127.0, 127.0, 1.0, 10.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
bc_tool->contrast_data = GTK_ADJUSTMENT (data);
slider = GIMP_SCALE_ENTRY_SCALE (data);
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
g_signal_connect (G_OBJECT (data), "value_changed",
G_CALLBACK (brightness_contrast_contrast_adjustment_update),

View File

@ -156,6 +156,8 @@ gimp_color_balance_tool_init (GimpColorBalanceTool *cb_tool)
image_map_tool->shell_title = _("Color Balance");
image_map_tool->shell_name = "color_balance";
image_map_tool->shell_desc = _("Adjust Color Balance");
image_map_tool->stock_id = GIMP_STOCK_TOOL_COLOR_BALANCE;
cb_tool->color_balance = g_new0 (ColorBalance, 1);
cb_tool->transfer_mode = GIMP_MIDTONES;
@ -188,8 +190,13 @@ gimp_color_balance_tool_initialize (GimpTool *tool,
cb_tool = GIMP_COLOR_BALANCE_TOOL (tool);
if (gdisp &&
! gimp_drawable_is_rgb (gimp_image_active_drawable (gdisp->gimage)))
if (! gdisp)
{
GIMP_TOOL_CLASS (parent_class)->initialize (tool, gdisp);
return;
}
if (! gimp_drawable_is_rgb (gimp_image_active_drawable (gdisp->gimage)))
{
g_message (_("Color balance operates only on RGB color drawables."));
return;
@ -333,7 +340,7 @@ gimp_color_balance_tool_dialog (GimpImageMapTool *image_map_tool)
gtk_box_pack_end (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
gtk_widget_show (vbox);
toggle = gtk_check_button_new_with_label (_("Preserve Luminosity"));
toggle = gtk_check_button_new_with_mnemonic (_("Preserve _Luminosity"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
cb_tool->color_balance->preserve_luminosity);
gtk_box_pack_end (GTK_BOX (vbox), toggle, FALSE, FALSE, 0);

View File

@ -242,6 +242,8 @@ gimp_curves_tool_init (GimpCurvesTool *c_tool)
image_map_tool->shell_title = _("Curves");
image_map_tool->shell_name = "curves";
image_map_tool->shell_desc = _("Adjust Color Curves");
image_map_tool->stock_id = GIMP_STOCK_TOOL_CURVES;
c_tool->curves = g_new0 (Curves, 1);
c_tool->lut = gimp_lut_new ();
@ -305,8 +307,13 @@ gimp_curves_tool_initialize (GimpTool *tool,
c_tool = GIMP_CURVES_TOOL (tool);
if (gdisp &&
gimp_drawable_is_indexed (gimp_image_active_drawable (gdisp->gimage)))
if (! gdisp)
{
GIMP_TOOL_CLASS (parent_class)->initialize (tool, gdisp);
return;
}
if (gimp_drawable_is_indexed (gimp_image_active_drawable (gdisp->gimage)))
{
g_message (_("Curves for indexed drawables cannot be adjusted."));
return;
@ -330,8 +337,8 @@ gimp_curves_tool_initialize (GimpTool *tool,
c_tool);
/* set the current selection */
gtk_option_menu_set_history (GTK_OPTION_MENU (c_tool->channel_menu),
c_tool->channel);
gimp_option_menu_set_history (GTK_OPTION_MENU (c_tool->channel_menu),
GINT_TO_POINTER (c_tool->channel));
curves_update (c_tool, ALL);
}
@ -399,25 +406,18 @@ gimp_curves_tool_button_release (GimpTool *tool,
if (state & GDK_SHIFT_MASK)
{
curves_add_point (c_tool,
coords->x, coords->y, c_tool->channel);
curves_add_point (c_tool, coords->x, coords->y, c_tool->channel);
curves_calculate_curve (c_tool->curves, c_tool->channel);
}
else if (state & GDK_CONTROL_MASK)
{
curves_add_point (c_tool,
coords->x, coords->y, GIMP_HISTOGRAM_VALUE);
curves_add_point (c_tool,
coords->x, coords->y, GIMP_HISTOGRAM_RED);
curves_add_point (c_tool,
coords->x, coords->y, GIMP_HISTOGRAM_GREEN);
curves_add_point (c_tool,
coords->x, coords->y, GIMP_HISTOGRAM_BLUE);
curves_add_point (c_tool,
coords->x, coords->y, GIMP_HISTOGRAM_ALPHA);
gint i;
curves_calculate_curve (c_tool->curves, c_tool->channel);
for (i = 0; i < 5; i++)
{
curves_add_point (c_tool, coords->x, coords->y, i);
curves_calculate_curve (c_tool->curves, c_tool->channel);
}
}
gimp_tool_control_halt (tool->control);
@ -482,9 +482,7 @@ curves_color_update (GimpTool *tool,
c_tool->col_value[GIMP_HISTOGRAM_BLUE] = color[BLUE_PIX];
if (has_alpha)
{
c_tool->col_value[GIMP_HISTOGRAM_ALPHA] = color[3];
}
c_tool->col_value[GIMP_HISTOGRAM_ALPHA] = color[3];
if (is_indexed)
c_tool->col_value[GIMP_HISTOGRAM_ALPHA] = color[4];
@ -562,6 +560,7 @@ gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool)
{
GimpCurvesTool *c_tool;
GtkWidget *hbox;
GtkWidget *vbox;
GtkWidget *hbbox;
GtkWidget *frame;
GtkWidget *table;
@ -569,11 +568,19 @@ gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool)
c_tool = GIMP_CURVES_TOOL (image_map_tool);
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (image_map_tool->main_vbox), hbox,
FALSE, FALSE, 0);
gtk_widget_show (hbox);
vbox = gtk_vbox_new (FALSE, 4);
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, FALSE, 0);
gtk_widget_show (vbox);
table = gtk_table_new (2, 2, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_box_pack_start (GTK_BOX (image_map_tool->main_vbox), table,
FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
gtk_widget_show (table);
/* The option menu for selecting channels */
@ -603,10 +610,10 @@ gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool)
gimp_option_menu_new (FALSE,
_("Smooth"), curves_smooth_callback,
c_tool, NULL, NULL, TRUE,
c_tool, GINT_TO_POINTER (CURVES_SMOOTH), NULL, TRUE,
_("Free"), curves_free_callback,
c_tool, NULL, NULL, FALSE,
c_tool, GINT_TO_POINTER (CURVES_FREE), NULL, FALSE,
NULL);
@ -618,8 +625,7 @@ gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool)
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 (image_map_tool->main_vbox), table,
FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
/* The range drawing area */
frame = gtk_frame_new (NULL);
@ -668,24 +674,31 @@ gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool)
gtk_widget_show (table);
/* Horizontal button box for load / save */
frame = gtk_frame_new (_("All Channels"));
gtk_box_pack_end (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
hbbox = gtk_hbutton_box_new ();
gtk_container_set_border_width (GTK_CONTAINER (hbbox), 2);
gtk_box_set_spacing (GTK_BOX (hbbox), 4);
gtk_button_box_set_layout (GTK_BUTTON_BOX (hbbox), GTK_BUTTONBOX_SPREAD);
gtk_box_pack_end (GTK_BOX (image_map_tool->main_vbox), hbbox, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER (frame), hbbox);
gtk_widget_show (hbbox);
button = gtk_button_new_with_label (_("Load"));
button = gtk_button_new_from_stock (GTK_STOCK_OPEN);
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
gimp_help_set_help_data (button, _("Read curves settings from file"), NULL);
gtk_widget_show (button);
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (curves_load_callback),
c_tool);
button = gtk_button_new_with_label (_("Save"));
button = gtk_button_new_from_stock (GTK_STOCK_SAVE);
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
gimp_help_set_help_data (button, _("Save curves settings to file"), NULL);
gtk_widget_show (button);
g_signal_connect (G_OBJECT (button), "clicked",
@ -762,16 +775,16 @@ static void
curves_update (GimpCurvesTool *c_tool,
gint update)
{
gint i, j;
gchar buf[32];
gint offset;
gint height;
gint sel_channel;
GimpHistogramChannel sel_channel;
gint i, j;
gchar buf[32];
gint offset;
gint height;
if (c_tool->color)
{
sel_channel = c_tool->channel;
}
}
else
{
if (c_tool->channel == 2)
@ -1005,8 +1018,8 @@ curves_channel_callback (GtkWidget *widget,
c_tool->channel = 1;
}
gtk_option_menu_set_history (GTK_OPTION_MENU (c_tool->curve_type_menu),
c_tool->curves->curve_type[c_tool->channel]);
gimp_option_menu_set_history (GTK_OPTION_MENU (c_tool->curve_type_menu),
GINT_TO_POINTER (c_tool->curves->curve_type[c_tool->channel]));
curves_update (c_tool, XRANGE_TOP | YRANGE | GRAPH | DRAW);
}
@ -1067,7 +1080,9 @@ curves_smooth_callback (GtkWidget *widget,
{
c_tool->curves->curve_type[c_tool->channel] = CURVES_SMOOTH;
/* pick representative points from the curve and make them control points */
/* pick representative points from the curve
* and make them control points
*/
for (i = 0; i <= 8; i++)
{
index = CLAMP0255 (i * 32);
@ -1482,8 +1497,9 @@ curves_read_from_file (GimpCurvesTool *c_tool,
curves_calculate_curve (c_tool->curves, i);
curves_update (c_tool, ALL);
gtk_option_menu_set_history (GTK_OPTION_MENU (c_tool->curve_type_menu),
CURVES_SMOOTH);
gimp_option_menu_set_history (GTK_OPTION_MENU (c_tool->curve_type_menu),
GINT_TO_POINTER (CURVES_SMOOTH));
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (c_tool));

View File

@ -57,24 +57,24 @@ typedef struct _HistogramToolDialog HistogramToolDialog;
struct _HistogramToolDialog
{
GtkWidget *shell;
GtkWidget *shell;
GtkWidget *info_labels[7];
GtkWidget *channel_menu;
GimpHistogramView *histogram;
GimpHistogram *hist;
GtkWidget *gradient;
GtkWidget *info_labels[7];
GtkWidget *channel_menu;
GimpHistogramView *histogram;
GimpHistogram *hist;
GtkWidget *gradient;
gdouble mean;
gdouble std_dev;
gdouble median;
gdouble pixels;
gdouble count;
gdouble percentile;
gdouble mean;
gdouble std_dev;
gdouble median;
gdouble pixels;
gdouble count;
gdouble percentile;
GimpDrawable *drawable;
gint channel;
gint color;
GimpDrawable *drawable;
GimpHistogramChannel channel;
gboolean color;
};
@ -91,24 +91,24 @@ static void gimp_histogram_tool_control (GimpTool *tool,
static HistogramToolDialog * histogram_tool_dialog_new (void);
static void histogram_tool_close_callback (GtkWidget *widget,
gpointer data);
static void histogram_tool_close_callback (GtkWidget *widget,
gpointer data);
static gboolean histogram_set_sensitive_callback
(gpointer item_data,
HistogramToolDialog *htd);
static void histogram_tool_channel_callback (GtkWidget *widget,
gpointer data);
static void histogram_tool_gradient_draw (GtkWidget *gdisp,
gint channel);
(gpointer item_data,
HistogramToolDialog *htd);
static void histogram_tool_channel_callback (GtkWidget *widget,
gpointer data);
static void histogram_tool_gradient_draw (GtkWidget *gradient,
GimpHistogramChannel channel);
static void histogram_tool_dialog_update (HistogramToolDialog *htd,
gint start,
gint end);
static void histogram_tool_dialog_update (HistogramToolDialog *htd,
gint start,
gint end);
static void histogram_tool_histogram_range (GimpHistogramView *view,
gint start,
gint end,
gpointer data);
static void histogram_tool_histogram_range (GimpHistogramView *view,
gint start,
gint end,
gpointer data);
static HistogramToolDialog * histogram_dialog = NULL;
@ -195,8 +195,8 @@ gimp_histogram_tool_initialize (GimpTool *tool,
/* The histogram_tool dialog */
if (! histogram_dialog)
histogram_dialog = histogram_tool_dialog_new ();
else if (!GTK_WIDGET_VISIBLE (histogram_dialog->shell))
gtk_widget_show (histogram_dialog->shell);
gtk_widget_show (histogram_dialog->shell);
histogram_dialog->drawable = gimp_image_active_drawable (gdisp->gimage);
histogram_dialog->color = gimp_drawable_is_rgb (histogram_dialog->drawable);
@ -328,17 +328,15 @@ static HistogramToolDialog *
histogram_tool_dialog_new (void)
{
HistogramToolDialog *htd;
GtkWidget *main_vbox;
GtkWidget *hbox;
GtkWidget *vbox;
GtkWidget *grad_hbox;
GtkWidget *frame;
GtkWidget *table;
GtkWidget *label;
gint i;
gint x, y;
gint i;
gint x, y;
static gchar * histogram_info_names[] =
static const gchar *histogram_info_names[] =
{
N_("Mean:"),
N_("Std Dev:"),
@ -349,7 +347,7 @@ histogram_tool_dialog_new (void)
N_("Percentile:")
};
htd = g_new (HistogramToolDialog, 1);
htd = g_new0 (HistogramToolDialog, 1);
htd->channel = GIMP_HISTOGRAM_VALUE;
htd->hist = gimp_histogram_new ();
@ -364,16 +362,13 @@ histogram_tool_dialog_new (void)
NULL);
main_vbox = gtk_vbox_new (FALSE, 4);
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 4);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (htd->shell)->vbox), main_vbox);
hbox = gtk_hbox_new (TRUE, 0);
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (htd->shell)->vbox), hbox);
gtk_widget_show (hbox);
vbox = gtk_vbox_new (FALSE, 4);
gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);;
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, FALSE, 0);
gtk_widget_show (vbox);
/* The option menu for selecting channels */
@ -396,37 +391,35 @@ histogram_tool_dialog_new (void)
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);
htd->histogram = gimp_histogram_view_new (HISTOGRAM_WIDTH, HISTOGRAM_HEIGHT);
gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET(htd->histogram));
gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (htd->histogram));
gtk_widget_show (GTK_WIDGET (htd->histogram));
g_signal_connect (G_OBJECT (htd->histogram), "range_changed",
G_CALLBACK (histogram_tool_histogram_range),
htd);
gtk_widget_show (GTK_WIDGET (htd->histogram));
gtk_widget_show (frame);
/* The gradient below the histogram */
grad_hbox = gtk_hbox_new (TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox), grad_hbox, FALSE, FALSE, 0);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (grad_hbox), frame, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
htd->gradient = gtk_preview_new (GTK_PREVIEW_COLOR);
gtk_preview_size (GTK_PREVIEW (htd->gradient),
HISTOGRAM_WIDTH, GRADIENT_HEIGHT);
gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET(htd->gradient));
gtk_widget_show (htd->gradient);
gtk_widget_show (frame);
gtk_widget_show (grad_hbox);
histogram_tool_gradient_draw (htd->gradient, GIMP_HISTOGRAM_VALUE);
/* The table containing histogram information */
table = gtk_table_new (4, 4, TRUE);
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
gtk_box_pack_start (GTK_BOX (main_vbox), table, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
gtk_widget_show (table);
/* the labels for histogram information */
for (i = 0; i < 7; i++)
@ -448,11 +441,6 @@ histogram_tool_dialog_new (void)
gtk_widget_show (htd->info_labels[i]);
}
gtk_widget_show (table);
gtk_widget_show (main_vbox);
gtk_widget_show (htd->shell);
return htd;
}
@ -509,8 +497,8 @@ histogram_set_sensitive_callback (gpointer item_data,
}
static void
histogram_tool_gradient_draw (GtkWidget *gradient,
gint channel)
histogram_tool_gradient_draw (GtkWidget *gradient,
GimpHistogramChannel channel)
{
guchar buf[HISTOGRAM_WIDTH * 3];
guchar r, g, b;
@ -532,17 +520,17 @@ histogram_tool_gradient_draw (GtkWidget *gradient,
g_warning ("unknown channel type, can't happen\n");
break;
}
for (i = 0; i < HISTOGRAM_WIDTH; i++)
{
buf[3*i+0] = i*r;
buf[3*i+1] = i*g;
buf[3*i+2] = i*b;
buf[3 * i + 0] = i * r;
buf[3 * i + 1] = i * g;
buf[3 * i + 2] = i * b;
}
for (i = 0; i < GRADIENT_HEIGHT; i++)
gtk_preview_draw_row (GTK_PREVIEW (gradient),
buf, 0, i, HISTOGRAM_WIDTH);
gtk_widget_queue_draw (gradient);
}

View File

@ -18,11 +18,6 @@
#include "config.h"
#ifdef __GNUC__
#warning GTK_DISABLE_DEPRECATED
#endif
#undef GTK_DISABLE_DEPRECATED
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
@ -45,13 +40,10 @@
#include "libgimp/gimpintl.h"
#define HUE_PARTITION_MASK GDK_EXPOSURE_MASK | GDK_ENTER_NOTIFY_MASK
#define SLIDER_WIDTH 200
#define DA_WIDTH 40
#define DA_HEIGHT 20
#define HUE_PARTITION 0x0
#define HUE_SLIDER 0x1
#define LIGHTNESS_SLIDER 0x2
#define SATURATION_SLIDER 0x4
@ -83,12 +75,9 @@ static void hue_saturation_lightness_adjustment_update (GtkAdjustment *adj,
gpointer data);
static void hue_saturation_saturation_adjustment_update (GtkAdjustment *adj,
gpointer data);
static gint hue_saturation_hue_partition_events (GtkWidget *widget,
GdkEvent *event,
GimpHueSaturationTool *hs_tool);
/* Local variables */
/* private variables */
static gint default_colors[6][3] =
{
@ -183,6 +172,8 @@ gimp_hue_saturation_tool_init (GimpHueSaturationTool *hs_tool)
image_map_tool->shell_title = _("Hue-Saturation");
image_map_tool->shell_name = "hue_saturation";
image_map_tool->shell_desc = _("Adjust Hue / Lightness / Saturation");
image_map_tool->stock_id = GIMP_STOCK_TOOL_HUE_SATURATION;
hs_tool->hue_saturation = g_new0 (HueSaturation, 1);
hs_tool->hue_partition = GIMP_ALL_HUES;
@ -213,8 +204,13 @@ gimp_hue_saturation_tool_initialize (GimpTool *tool,
hs_tool = GIMP_HUE_SATURATION_TOOL (tool);
if (gdisp &&
! gimp_drawable_is_rgb (gimp_image_active_drawable (gdisp->gimage)))
if (! gdisp)
{
GIMP_TOOL_CLASS (parent_class)->initialize (tool, gdisp);
return;
}
if (! gimp_drawable_is_rgb (gimp_image_active_drawable (gdisp->gimage)))
{
g_message (_("Hue-Saturation operates only on RGB color drawables."));
return;
@ -255,80 +251,90 @@ static void
gimp_hue_saturation_tool_dialog (GimpImageMapTool *image_map_tool)
{
GimpHueSaturationTool *hs_tool;
GtkWidget *main_hbox;
GtkWidget *vbox;
GtkWidget *table;
GtkWidget *label;
GtkWidget *slider;
GtkWidget *abox;
GtkWidget *spinbutton;
GtkWidget *table;
GtkWidget *slider;
GtkWidget *radio_button;
GtkWidget *frame;
GtkObject *data;
GSList *group = NULL;
gint i;
gchar *hue_partition_names[] =
const struct
{
N_("Master"),
N_("R"),
N_("Y"),
N_("G"),
N_("C"),
N_("B"),
N_("M")
const gchar *label;
gint label_col;
gint label_row;
gint frame_col;
gint frame_row;
}
hue_partition_table[] =
{
{ N_("_Master"), 2, 3, 0, 0 },
{ N_("_R"), 2, 1, 2, 0 },
{ N_("_Y"), 1, 2, 0, 2 },
{ N_("_G"), 1, 4, 0, 4 },
{ N_("_C"), 2, 5, 2, 6 },
{ N_("_B"), 3, 4, 4, 4 },
{ N_("_M"), 3, 2, 4, 2 }
};
hs_tool = GIMP_HUE_SATURATION_TOOL (image_map_tool);
/* The main hbox containing hue partitions and sliders */
main_hbox = gtk_hbox_new (FALSE, 12);
gtk_box_pack_start (GTK_BOX (image_map_tool->main_vbox), main_hbox,
abox = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_box_pack_start (GTK_BOX (image_map_tool->main_vbox), abox,
FALSE, FALSE, 0);
gtk_widget_show (abox);
/* The table containing hue partitions */
table = gtk_table_new (7, 2, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_box_pack_start (GTK_BOX (main_hbox), table, FALSE, FALSE, 0);
table = gtk_table_new (7, 5, FALSE);
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4);
gtk_table_set_col_spacing (GTK_TABLE (table), 3, 4);
gtk_table_set_row_spacing (GTK_TABLE (table), 0, 2);
gtk_table_set_row_spacing (GTK_TABLE (table), 5, 2);
gtk_container_add (GTK_CONTAINER (abox), table);
/* the radio buttons for hue partitions */
for (i = 0; i < 7; i++)
{
radio_button = gtk_radio_button_new_with_label (group, gettext (hue_partition_names[i]));
radio_button = gtk_radio_button_new_with_mnemonic (group, gettext (hue_partition_table[i].label));
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_button));
g_object_set_data (G_OBJECT (radio_button), "hue_partition",
GINT_TO_POINTER (i));
if (!i)
{
gtk_table_attach (GTK_TABLE (table), radio_button, 0, 2, 0, 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
}
else
{
gtk_table_attach (GTK_TABLE (table), radio_button, 0, 1, i, i + 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
if (i == 0)
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (radio_button), FALSE);
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, i, i + 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table), radio_button,
hue_partition_table[i].label_col,
hue_partition_table[i].label_col + 1,
hue_partition_table[i].label_row,
hue_partition_table[i].label_row + 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
if (i > 0)
{
GimpRGB color = { 0.0 };
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_table_attach (GTK_TABLE (table), frame,
hue_partition_table[i].frame_col,
hue_partition_table[i].frame_col + 1,
hue_partition_table[i].frame_row,
hue_partition_table[i].frame_row + 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (frame);
hs_tool->hue_partition_da[i - 1] = gtk_preview_new (GTK_PREVIEW_COLOR);
gtk_preview_size (GTK_PREVIEW (hs_tool->hue_partition_da[i - 1]),
DA_WIDTH, DA_HEIGHT);
gtk_widget_set_events (hs_tool->hue_partition_da[i - 1],
HUE_PARTITION_MASK);
gtk_container_add (GTK_CONTAINER (frame),
hs_tool->hue_partition_da[i - 1] = gimp_color_area_new (&color,
GIMP_COLOR_AREA_FLAT,
0);
gtk_widget_set_size_request (hs_tool->hue_partition_da[i - 1],
DA_WIDTH, DA_HEIGHT);
gtk_container_add (GTK_CONTAINER (frame),
hs_tool->hue_partition_da[i - 1]);
gtk_widget_show (hs_tool->hue_partition_da[i - 1]);
g_signal_connect (G_OBJECT (hs_tool->hue_partition_da[i - 1]), "event",
G_CALLBACK (hue_saturation_hue_partition_events),
hs_tool);
}
gtk_widget_show (hs_tool->hue_partition_da[i - 1]);
}
g_signal_connect (G_OBJECT (radio_button), "toggled",
G_CALLBACK (hue_saturation_partition_callback),
@ -339,127 +345,60 @@ gimp_hue_saturation_tool_dialog (GimpImageMapTool *image_map_tool)
gtk_widget_show (table);
/* The vbox for the table and preview toggle */
vbox = gtk_vbox_new (FALSE, 4);
gtk_box_pack_start (GTK_BOX (main_hbox), vbox, FALSE, FALSE, 0);
label = gtk_label_new (_("Hue / Lightness / Saturation Adjustments"));
gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5);
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
frame = gtk_frame_new (_("Modify Selected Color"));
gtk_box_pack_start (GTK_BOX (image_map_tool->main_vbox), frame,
FALSE, FALSE, 0);
gtk_widget_show (frame);
/* The table containing sliders */
table = gtk_table_new (3, 3, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (table), 2);
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show (table);
/* Create the hue scale widget */
label = gtk_label_new (_("Hue:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
data = gtk_adjustment_new (0, -180, 180.0, 1.0, 1.0, 0.0);
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
_("_Hue:"), SLIDER_WIDTH, 75,
0.0, -180.0, 180.0, 1.0, 15.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
hs_tool->hue_data = GTK_ADJUSTMENT (data);
slider = gtk_hscale_new (hs_tool->hue_data);
gtk_widget_set_size_request (slider, SLIDER_WIDTH, -1);
gtk_scale_set_digits (GTK_SCALE (slider), 0);
gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP);
slider = GIMP_SCALE_ENTRY_SCALE (data);
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
gtk_table_attach (GTK_TABLE (table), slider, 1, 2, 0, 1,
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
abox = gtk_vbox_new (FALSE, 0);
spinbutton = gtk_spin_button_new (hs_tool->hue_data, 1.0, 0);
gtk_widget_set_size_request (spinbutton, 74, -1);
gtk_box_pack_end (GTK_BOX (abox), spinbutton, FALSE, FALSE, 0);
gtk_table_attach (GTK_TABLE (table), abox, 2, 3, 0, 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
g_signal_connect (G_OBJECT (hs_tool->hue_data), "value_changed",
g_signal_connect (G_OBJECT (data), "value_changed",
G_CALLBACK (hue_saturation_hue_adjustment_update),
hs_tool);
gtk_widget_show (label);
gtk_widget_show (slider);
gtk_widget_show (spinbutton);
gtk_widget_show (abox);
/* Create the lightness scale widget */
label = gtk_label_new (_("Lightness:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
data = gtk_adjustment_new (0, -100.0, 100.0, 1.0, 1.0, 0.0);
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 1,
_("_Lightness:"), SLIDER_WIDTH, 75,
0.0, -100.0, 100.0, 1.0, 10.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
hs_tool->lightness_data = GTK_ADJUSTMENT (data);
slider = gtk_hscale_new (hs_tool->lightness_data);
gtk_widget_set_size_request (slider, SLIDER_WIDTH, -1);
gtk_scale_set_digits (GTK_SCALE (slider), 0);
gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP);
slider = GIMP_SCALE_ENTRY_SCALE (data);
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
gtk_table_attach (GTK_TABLE (table), slider, 1, 2, 1, 2,
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
abox = gtk_vbox_new (FALSE, 0);
spinbutton = gtk_spin_button_new (hs_tool->lightness_data, 1.0, 0);
gtk_widget_set_size_request (spinbutton, 75, -1);
gtk_box_pack_end (GTK_BOX (abox), spinbutton, FALSE, FALSE, 0);
gtk_table_attach (GTK_TABLE (table), abox, 2, 3, 1, 2,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
g_signal_connect (G_OBJECT (hs_tool->lightness_data), "value_changed",
g_signal_connect (G_OBJECT (data), "value_changed",
G_CALLBACK (hue_saturation_lightness_adjustment_update),
hs_tool);
gtk_widget_show (label);
gtk_widget_show (slider);
gtk_widget_show (spinbutton);
gtk_widget_show (abox);
/* Create the saturation scale widget */
label = gtk_label_new (_("Saturation:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
data = gtk_adjustment_new (0, -100.0, 100.0, 1.0, 1.0, 0.0);
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 2,
_("_Saturation:"), SLIDER_WIDTH, 75,
0.0, -100.0, 100.0, 1.0, 10.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
hs_tool->saturation_data = GTK_ADJUSTMENT (data);
slider = gtk_hscale_new (hs_tool->saturation_data);
gtk_widget_set_size_request (slider, SLIDER_WIDTH, -1);
gtk_scale_set_digits (GTK_SCALE (slider), 0);
gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP);
slider = GIMP_SCALE_ENTRY_SCALE (data);
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
gtk_table_attach (GTK_TABLE (table), slider, 1, 2, 2, 3,
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
abox = gtk_vbox_new (FALSE, 0);
spinbutton = gtk_spin_button_new (hs_tool->saturation_data, 1.0, 0);
gtk_widget_set_size_request (spinbutton, 75, -1);
gtk_box_pack_end (GTK_BOX (abox), spinbutton, FALSE, FALSE, 0);
gtk_table_attach (GTK_TABLE (table), abox, 2, 3, 2, 3,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
g_signal_connect (G_OBJECT (hs_tool->saturation_data), "value_changed",
G_CALLBACK (hue_saturation_saturation_adjustment_update),
hs_tool);
gtk_widget_show (label);
gtk_widget_show (slider);
gtk_widget_show (spinbutton);
gtk_widget_show (abox);
gtk_widget_show (table);
gtk_widget_show (vbox);
gtk_widget_show (main_hbox);
}
static void
@ -480,9 +419,9 @@ static void
hue_saturation_update (GimpHueSaturationTool *hs_tool,
gint update)
{
gint i, j, b;
gint rgb[3];
guchar buf[DA_WIDTH * 3];
gint rgb[3];
GimpRGB color;
gint i;
if (update & HUE_SLIDER)
gtk_adjustment_set_value (GTK_ADJUSTMENT (hs_tool->hue_data),
@ -512,16 +451,11 @@ hue_saturation_update (GimpHueSaturationTool *hs_tool,
gimp_hls_to_rgb_int (rgb, rgb + 1, rgb + 2);
for (j = 0; j < DA_WIDTH; j++)
for (b = 0; b < 3; b++)
buf[j * 3 + b] = (guchar) rgb[b];
gimp_rgb_set_uchar (&color,
(guchar) rgb[0], (guchar) rgb[1], (guchar) rgb[2]);
for (j = 0; j < DA_HEIGHT; j++)
gtk_preview_draw_row (GTK_PREVIEW (hs_tool->hue_partition_da[i]),
buf, 0, j, DA_WIDTH);
if (update & DRAW)
gtk_widget_queue_draw (hs_tool->hue_partition_da[i]);
gimp_color_area_set_color (GIMP_COLOR_AREA (hs_tool->hue_partition_da[i]),
&color);
}
}
@ -600,21 +534,3 @@ hue_saturation_saturation_adjustment_update (GtkAdjustment *adjustment,
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (hs_tool));
}
}
static gint
hue_saturation_hue_partition_events (GtkWidget *widget,
GdkEvent *event,
GimpHueSaturationTool *hs_tool)
{
switch (event->type)
{
case GDK_EXPOSE:
hue_saturation_update (hs_tool, HUE_PARTITION);
break;
default:
break;
}
return FALSE;
}

View File

@ -192,18 +192,19 @@ gimp_image_map_tool_initialize (GimpTool *tool,
if (! gdisp)
{
gimp_image_map_tool_cancel_clicked (NULL, image_map_tool);
if (image_map_tool->shell)
gimp_image_map_tool_cancel_clicked (NULL, image_map_tool);
return;
}
drawable = gimp_image_active_drawable (gdisp->gimage);
if (! image_map_tool->shell)
{
GtkWidget *shell;
GtkWidget *frame;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *image;
GtkWidget *preview;
GtkWidget *label;
GtkWidget *toggle;
@ -233,31 +234,45 @@ gimp_image_map_tool_initialize (GimpTool *tool,
gtk_widget_show (frame);
hbox = gtk_hbox_new (FALSE, 4);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 4);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 2);
gtk_container_add (GTK_CONTAINER (frame), hbox);
gtk_widget_show (hbox);
image = gtk_image_new_from_stock (image_map_tool->stock_id,
GTK_ICON_SIZE_BUTTON);
gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
gtk_widget_show (image);
image_map_tool->title_preview = preview =
gimp_preview_new_by_type (GIMP_TYPE_DRAWABLE, 32, 1, FALSE);
gtk_box_pack_start (GTK_BOX (hbox), preview, FALSE, FALSE, 0);
gimp_preview_new_by_type (GIMP_TYPE_DRAWABLE, 32, 1, TRUE);
gtk_box_pack_end (GTK_BOX (hbox), preview, FALSE, FALSE, 0);
gtk_widget_show (preview);
vbox = gtk_vbox_new (FALSE, 2);
gtk_container_add (GTK_CONTAINER (hbox), vbox);
gtk_widget_show (vbox);
label = gtk_label_new (image_map_tool->shell_desc);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
image_map_tool->title_label = label = gtk_label_new (NULL);
//gtk_widget_set_size_request (label, 0, -1);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_box_pack_end (GTK_BOX (vbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
image_map_tool->main_vbox = vbox = gtk_vbox_new (FALSE, 4);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (shell)->vbox), vbox);
/* Horizontal box for preview */
hbox = gtk_hbox_new (FALSE, 4);
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_end (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
/* The preview toggle */
toggle = gtk_check_button_new_with_label (_("Preview"));
toggle = gtk_check_button_new_with_mnemonic (_("_Preview"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
image_map_tool->preview);
gtk_box_pack_end (GTK_BOX (hbox), toggle, FALSE, FALSE, 0);
@ -273,11 +288,12 @@ gimp_image_map_tool_initialize (GimpTool *tool,
gtk_widget_show (vbox);
}
drawable = gimp_image_active_drawable (gdisp->gimage);
basename =
file_utils_uri_to_utf8_basename (gimp_image_get_uri (gdisp->gimage));
str = g_strdup_printf ("%s\n%s (%s)",
image_map_tool->shell_title,
str = g_strdup_printf ("%s (%s)",
basename,
gimp_object_get_name (GIMP_OBJECT (drawable)));

View File

@ -46,6 +46,9 @@ struct _GimpImageMapTool
/* the dialog */
const gchar *shell_title;
const gchar *shell_name;
const gchar *shell_desc;
const gchar *stock_id;
GtkWidget *shell;
GtkWidget *title_preview;
GtkWidget *title_label;

View File

@ -222,6 +222,8 @@ gimp_levels_tool_init (GimpLevelsTool *l_tool)
image_map_tool->shell_title = _("Levels");
image_map_tool->shell_name = "levels";
image_map_tool->shell_desc = _("Adjust Color Levels");
image_map_tool->stock_id = GIMP_STOCK_TOOL_LEVELS;
l_tool->lut = gimp_lut_new ();
l_tool->hist = gimp_histogram_new ();
@ -260,8 +262,13 @@ gimp_levels_tool_initialize (GimpTool *tool,
l_tool = GIMP_LEVELS_TOOL (tool);
if (gdisp &&
gimp_drawable_is_indexed (gimp_image_active_drawable (gdisp->gimage)))
if (! gdisp)
{
GIMP_TOOL_CLASS (parent_class)->initialize (tool, gdisp);
return;
}
if (gimp_drawable_is_indexed (gimp_image_active_drawable (gdisp->gimage)))
{
g_message (_("Levels for indexed drawables cannot be adjusted."));
return;
@ -377,19 +384,18 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
hbox = gtk_hbox_new (TRUE, 2);
gtk_container_add (GTK_CONTAINER (frame), hbox);
gtk_widget_show (hbox);
vbox2 = gtk_vbox_new (FALSE, 4);
gtk_container_set_border_width (GTK_CONTAINER (vbox2), 2);
gtk_container_add (GTK_CONTAINER (frame), vbox2);
gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, FALSE, 0);
gtk_widget_show (vbox2);
/* The levels histogram */
hbox = gtk_hbox_new (TRUE, 2);
gtk_box_pack_start (GTK_BOX (vbox2), hbox, TRUE, FALSE, 0);
gtk_widget_show (hbox);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox2), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
l_tool->histogram = gimp_histogram_view_new (HISTOGRAM_WIDTH,
@ -494,19 +500,18 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
hbox = gtk_hbox_new (TRUE, 2);
gtk_container_add (GTK_CONTAINER (frame), hbox);
gtk_widget_show (hbox);
vbox2 = gtk_vbox_new (FALSE, 4);
gtk_container_set_border_width (GTK_CONTAINER (vbox2), 2);
gtk_container_add (GTK_CONTAINER (frame), vbox2);
gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, FALSE, 0);
gtk_widget_show (vbox2);
/* The output levels drawing area */
hbox = gtk_hbox_new (TRUE, 2);
gtk_box_pack_start (GTK_BOX (vbox2), hbox, TRUE, FALSE, 0);
gtk_widget_show (hbox);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox2), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
vbox3 = gtk_vbox_new (FALSE, 2);
@ -572,34 +577,41 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
/* Horizontal button box for auto / load / save */
frame = gtk_frame_new (_("All Channels"));
gtk_box_pack_end (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
hbbox = gtk_hbutton_box_new ();
gtk_container_set_border_width (GTK_CONTAINER (hbbox), 2);
gtk_box_set_spacing (GTK_BOX (hbbox), 4);
gtk_button_box_set_layout (GTK_BUTTON_BOX (hbbox), GTK_BUTTONBOX_SPREAD);
gtk_box_pack_end (GTK_BOX (image_map_tool->main_vbox), hbbox,
FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER (frame), hbbox);
gtk_widget_show (hbbox);
button = gtk_button_new_with_label (_("Auto"));
button = gtk_button_new_with_mnemonic (_("_Auto"));
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
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 (G_OBJECT (button), "clicked",
G_CALLBACK (levels_auto_callback),
l_tool);
button = gtk_button_new_with_label (_("Load"));
button = gtk_button_new_from_stock (GTK_STOCK_OPEN);
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
gimp_help_set_help_data (button, _("Read levels settings from file"), NULL);
gtk_widget_show (button);
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (levels_load_callback),
l_tool);
button = gtk_button_new_with_label (_("Save"));
button = gtk_button_new_from_stock (GTK_STOCK_SAVE);
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
gimp_help_set_help_data (button, _("Save levels settings to file"), NULL);
gtk_widget_show (button);
g_signal_connect (G_OBJECT (button), "clicked",

View File

@ -140,6 +140,8 @@ gimp_posterize_tool_init (GimpPosterizeTool *posterize_tool)
image_map_tool->shell_title = _("Posterize");
image_map_tool->shell_name = "posterize";
image_map_tool->shell_desc = _("Posterize (Reduce Number of Colors)");
image_map_tool->stock_id = GIMP_STOCK_TOOL_POSTERIZE;
posterize_tool->levels = POSTERIZE_DEFAULT_LEVELS;
posterize_tool->lut = gimp_lut_new ();
@ -169,8 +171,13 @@ gimp_posterize_tool_initialize (GimpTool *tool,
posterize_tool = GIMP_POSTERIZE_TOOL (tool);
if (gdisp &&
gimp_drawable_is_indexed (gimp_image_active_drawable (gdisp->gimage)))
if (! gdisp)
{
GIMP_TOOL_CLASS (parent_class)->initialize (tool, gdisp);
return;
}
if (gimp_drawable_is_indexed (gimp_image_active_drawable (gdisp->gimage)))
{
g_message (_("Posterize does not operate on indexed drawables."));
return;
@ -213,6 +220,7 @@ gimp_posterize_tool_dialog (GimpImageMapTool *image_map_tool)
{
GimpPosterizeTool *posterize_tool;
GtkWidget *table;
GtkWidget *slider;
GtkObject *data;
posterize_tool = GIMP_POSTERIZE_TOOL (image_map_tool);
@ -225,14 +233,15 @@ gimp_posterize_tool_dialog (GimpImageMapTool *image_map_tool)
gtk_widget_show (table);
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
_("Posterize Levels:"),
_("Posterize _Levels:"),
SLIDER_WIDTH, 75,
posterize_tool->levels,
2.0, 256.0, 1.0, 10.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
posterize_tool->levels_data = GTK_ADJUSTMENT (data);
slider = GIMP_SCALE_ENTRY_SCALE (data);
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
g_signal_connect (G_OBJECT (posterize_tool->levels_data), "value_changed",
G_CALLBACK (posterize_levels_adjustment_update),

View File

@ -160,6 +160,8 @@ gimp_threshold_tool_init (GimpThresholdTool *t_tool)
image_map_tool->shell_title = _("Threshold");
image_map_tool->shell_name = "threshold";
image_map_tool->shell_desc = _("Apply Threshold");
image_map_tool->stock_id = GIMP_STOCK_TOOL_THRESHOLD;
t_tool->threshold = g_new0 (Threshold, 1);
t_tool->hist = gimp_histogram_new ();
@ -199,8 +201,13 @@ gimp_threshold_tool_initialize (GimpTool *tool,
t_tool = GIMP_THRESHOLD_TOOL (tool);
if (gdisp &&
gimp_drawable_is_indexed (gimp_image_active_drawable (gdisp->gimage)))
if (! gdisp)
{
GIMP_TOOL_CLASS (parent_class)->initialize (tool, gdisp);
return;
}
if (gimp_drawable_is_indexed (gimp_image_active_drawable (gdisp->gimage)))
{
g_message (_("Threshold does not operate on indexed drawables."));
return;
@ -251,6 +258,7 @@ gimp_threshold_tool_dialog (GimpImageMapTool *image_map_tool)
{
GimpThresholdTool *t_tool;
GtkWidget *hbox;
GtkWidget *vbox;
GtkWidget *spinbutton;
GtkWidget *label;
GtkWidget *frame;
@ -258,10 +266,17 @@ gimp_threshold_tool_dialog (GimpImageMapTool *image_map_tool)
t_tool = GIMP_THRESHOLD_TOOL (image_map_tool);
/* Horizontal box for threshold text widget */
hbox = gtk_hbox_new (TRUE, 0);
gtk_container_add (GTK_CONTAINER (image_map_tool->main_vbox), hbox);
gtk_widget_show (hbox);
vbox = gtk_vbox_new (FALSE, 4);
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, FALSE, 0);
gtk_widget_show (vbox);
hbox = gtk_hbox_new (FALSE, 4);
gtk_box_pack_start (GTK_BOX (image_map_tool->main_vbox), hbox,
FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
label = gtk_label_new (_("Threshold Range:"));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
@ -295,17 +310,10 @@ gimp_threshold_tool_dialog (GimpImageMapTool *image_map_tool)
G_CALLBACK (threshold_high_threshold_adjustment_update),
t_tool);
gtk_widget_show (hbox);
/* The threshold histogram */
hbox = gtk_hbox_new (TRUE, 0);
gtk_box_pack_start (GTK_BOX (image_map_tool->main_vbox), hbox,
FALSE, FALSE, 0);
gtk_widget_show (hbox);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
t_tool->histogram = gimp_histogram_view_new (HISTOGRAM_WIDTH,