Commit b8ca2856 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

add "GObject **config" return value to GimpImageMapTool::get_operation()

2008-01-30  Michael Natterer  <mitch@gimp.org>

	* app/tools/gimpimagemaptool.[ch]: add "GObject **config" return
	value to GimpImageMapTool::get_operation() and memory-manage the
	config object here.

	Add default implementation of GimpImageMapTool::reset() which
	calls gimp_config_reset() on the config object.

	* app/tools/gimpbrightnesscontrasttool.c
	* app/tools/gimpcolorbalancetool.c
	* app/tools/gimpcolorizetool.c
	* app/tools/gimpcurvestool.c
	* app/tools/gimphuesaturationtool.c
	* app/tools/gimplevelstool.c
	* app/tools/gimpposterizetool.c
	* app/tools/gimpthresholdtool.c: return the config object in
	get_operation() and don't unref it in finalize().

	Connect to the config object's "notify" signal and update the GUI
	in the callback. Also call gimp_image_map_tool_preview() there.
	Removed all other GUI update functions and all calls to preview().

	Removed reset() implementations which only called
	gimp_config_reset().


svn path=/trunk/; revision=24752
parent 2abe1667
2008-01-30 Michael Natterer <mitch@gimp.org>
* app/tools/gimpimagemaptool.[ch]: add "GObject **config" return
value to GimpImageMapTool::get_operation() and memory-manage the
config object here.
Add default implementation of GimpImageMapTool::reset() which
calls gimp_config_reset() on the config object.
* app/tools/gimpbrightnesscontrasttool.c
* app/tools/gimpcolorbalancetool.c
* app/tools/gimpcolorizetool.c
* app/tools/gimpcurvestool.c
* app/tools/gimphuesaturationtool.c
* app/tools/gimplevelstool.c
* app/tools/gimpposterizetool.c
* app/tools/gimpthresholdtool.c: return the config object in
get_operation() and don't unref it in finalize().
Connect to the config object's "notify" signal and update the GUI
in the callback. Also call gimp_image_map_tool_preview() there.
Removed all other GUI update functions and all calls to preview().
Removed reset() implementations which only called
gimp_config_reset().
2008-01-30 Michael Natterer <mitch@gimp.org>
* app/widgets/gimphistogramview.c
......
......@@ -18,6 +18,8 @@
#include "config.h"
#include <string.h>
#include <gegl.h>
#include <gtk/gtk.h>
......@@ -72,12 +74,15 @@ static void gimp_brightness_contrast_tool_motion (GimpTool
GimpDisplay *display);
static GeglNode *
gimp_brightness_contrast_tool_get_operation (GimpImageMapTool *image_map_tool);
gimp_brightness_contrast_tool_get_operation (GimpImageMapTool *image_map_tool,
GObject **config);
static void gimp_brightness_contrast_tool_map (GimpImageMapTool *image_map_tool);
static void gimp_brightness_contrast_tool_dialog (GimpImageMapTool *image_map_tool);
static void gimp_brightness_contrast_tool_reset (GimpImageMapTool *image_map_tool);
static void brightness_contrast_update_sliders (GimpBrightnessContrastTool *bc_tool);
static void brightness_contrast_config_notify (GObject *object,
GParamSpec *pspec,
GimpBrightnessContrastTool *bc_tool);
static void brightness_contrast_brightness_changed (GtkAdjustment *adj,
GimpBrightnessContrastTool *bc_tool);
static void brightness_contrast_contrast_changed (GtkAdjustment *adj,
......@@ -125,7 +130,6 @@ gimp_brightness_contrast_tool_class_init (GimpBrightnessContrastToolClass *klass
im_tool_class->get_operation = gimp_brightness_contrast_tool_get_operation;
im_tool_class->map = gimp_brightness_contrast_tool_map;
im_tool_class->dialog = gimp_brightness_contrast_tool_dialog;
im_tool_class->reset = gimp_brightness_contrast_tool_reset;
}
static void
......@@ -144,12 +148,6 @@ gimp_brightness_contrast_tool_finalize (GObject *object)
{
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (object);
if (bc_tool->config)
{
g_object_unref (bc_tool->config);
bc_tool->config = NULL;
}
if (bc_tool->lut)
{
gimp_lut_free (bc_tool->lut);
......@@ -183,18 +181,23 @@ gimp_brightness_contrast_tool_initialize (GimpTool *tool,
GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
brightness_contrast_update_sliders (bc_tool);
return TRUE;
}
static GeglNode *
gimp_brightness_contrast_tool_get_operation (GimpImageMapTool *im_tool)
gimp_brightness_contrast_tool_get_operation (GimpImageMapTool *im_tool,
GObject **config)
{
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (im_tool);
bc_tool->config = g_object_new (GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG, NULL);
*config = G_OBJECT (bc_tool->config);
g_signal_connect_object (bc_tool->config, "notify",
G_CALLBACK (brightness_contrast_config_notify),
G_OBJECT (bc_tool), 0);
return g_object_new (GEGL_TYPE_NODE,
"operation", "brightness-contrast",
NULL);
......@@ -250,7 +253,7 @@ gimp_brightness_contrast_tool_button_release (GimpTool *tool,
return;
if (release_type == GIMP_BUTTON_RELEASE_CANCEL)
gimp_brightness_contrast_tool_reset (im_tool);
gimp_config_reset (GIMP_CONFIG (bc_tool->config));
gimp_image_map_tool_preview (im_tool);
}
......@@ -263,18 +266,16 @@ gimp_brightness_contrast_tool_motion (GimpTool *tool,
GimpDisplay *display)
{
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (tool);
GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (tool);
gimp_tool_control_pause (tool->control);
bc_tool->dx = (coords->x - bc_tool->x);
bc_tool->dy = - (coords->y - bc_tool->y);
bc_tool->config->brightness = CLAMP (bc_tool->dy, -127.0, 127.0) / 127.0;
bc_tool->config->contrast = CLAMP (bc_tool->dx, -127.0, 127.0) / 127.0;
brightness_contrast_update_sliders (bc_tool);
gimp_image_map_tool_preview (im_tool);
g_object_set (bc_tool->config,
"brightness", CLAMP (bc_tool->dy, -127.0, 127.0) / 127.0,
"contrast", CLAMP (bc_tool->dx, -127.0, 127.0) / 127.0,
NULL);
gimp_tool_control_resume (tool->control);
}
......@@ -287,10 +288,11 @@ gimp_brightness_contrast_tool_motion (GimpTool *tool,
static void
gimp_brightness_contrast_tool_dialog (GimpImageMapTool *im_tool)
{
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (im_tool);
GtkWidget *table;
GtkWidget *slider;
GtkObject *data;
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (im_tool);
GimpBrightnessContrastConfig *config = bc_tool->config;
GtkWidget *table;
GtkWidget *slider;
GtkObject *data;
/* The table containing sliders */
table = gtk_table_new (2, 3, FALSE);
......@@ -303,7 +305,7 @@ gimp_brightness_contrast_tool_dialog (GimpImageMapTool *im_tool)
/* Create the brightness scale widget */
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
_("_Brightness:"), SLIDER_WIDTH, -1,
bc_tool->config->brightness * 127.0,
config->brightness * 127.0,
-127.0, 127.0, 1.0, 10.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
......@@ -318,7 +320,7 @@ gimp_brightness_contrast_tool_dialog (GimpImageMapTool *im_tool)
/* Create the contrast scale widget */
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 1,
_("Con_trast:"), SLIDER_WIDTH, -1,
bc_tool->config->contrast * 127.0,
config->contrast * 127.0,
-127.0, 127.0, 1.0, 10.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
......@@ -332,22 +334,27 @@ gimp_brightness_contrast_tool_dialog (GimpImageMapTool *im_tool)
}
static void
gimp_brightness_contrast_tool_reset (GimpImageMapTool *im_tool)
brightness_contrast_config_notify (GObject *object,
GParamSpec *pspec,
GimpBrightnessContrastTool *bc_tool)
{
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (im_tool);
GimpBrightnessContrastConfig *config = GIMP_BRIGHTNESS_CONTRAST_CONFIG (object);
gimp_config_reset (GIMP_CONFIG (bc_tool->config));
if (! bc_tool->brightness_data)
return;
brightness_contrast_update_sliders (bc_tool);
}
if (! strcmp (pspec->name, "brightness"))
{
gtk_adjustment_set_value (bc_tool->brightness_data,
config->brightness * 127.0);
}
else if (! strcmp (pspec->name, "contrast"))
{
gtk_adjustment_set_value (bc_tool->contrast_data,
config->contrast * 127.0);
}
static void
brightness_contrast_update_sliders (GimpBrightnessContrastTool *bc_tool)
{
gtk_adjustment_set_value (bc_tool->brightness_data,
bc_tool->config->brightness * 127.0);
gtk_adjustment_set_value (bc_tool->contrast_data,
bc_tool->config->contrast * 127.0);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (bc_tool));
}
static void
......@@ -362,8 +369,6 @@ brightness_contrast_brightness_changed (GtkAdjustment *adjustment,
g_object_set (config,
"brightness", value,
NULL);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (bc_tool));
}
}
......@@ -379,7 +384,5 @@ brightness_contrast_contrast_changed (GtkAdjustment *adjustment,
g_object_set (config,
"contrast", value,
NULL);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (bc_tool));
}
}
......@@ -18,6 +18,8 @@
#include "config.h"
#include <string.h>
#include <gegl.h>
#include <gtk/gtk.h>
......@@ -51,12 +53,16 @@ static gboolean gimp_color_balance_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error);
static GeglNode * gimp_color_balance_tool_get_operation (GimpImageMapTool *im_tool);
static GeglNode * gimp_color_balance_tool_get_operation (GimpImageMapTool *im_tool,
GObject **config);
static void gimp_color_balance_tool_map (GimpImageMapTool *im_tool);
static void gimp_color_balance_tool_dialog (GimpImageMapTool *im_tool);
static void gimp_color_balance_tool_reset (GimpImageMapTool *im_tool);
static void color_balance_update (GimpColorBalanceTool *cb_tool);
static void color_balance_config_notify (GObject *object,
GParamSpec *pspec,
GimpColorBalanceTool *cb_tool);
static void color_balance_range_callback (GtkWidget *widget,
GimpColorBalanceTool *cb_tool);
static void color_balance_range_reset_callback (GtkWidget *widget,
......@@ -130,12 +136,6 @@ gimp_color_balance_tool_finalize (GObject *object)
{
GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (object);
if (cb_tool->config)
{
g_object_unref (cb_tool->config);
cb_tool->config = NULL;
}
g_slice_free (ColorBalance, cb_tool->color_balance);
G_OBJECT_CLASS (parent_class)->finalize (object);
......@@ -165,16 +165,12 @@ gimp_color_balance_tool_initialize (GimpTool *tool,
GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (cb_tool->range_radio),
cb_tool->config->range);
color_balance_update (cb_tool);
return TRUE;
}
static GeglNode *
gimp_color_balance_tool_get_operation (GimpImageMapTool *im_tool)
gimp_color_balance_tool_get_operation (GimpImageMapTool *im_tool,
GObject **config)
{
GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (im_tool);
GeglNode *node;
......@@ -185,6 +181,12 @@ gimp_color_balance_tool_get_operation (GimpImageMapTool *im_tool)
cb_tool->config = g_object_new (GIMP_TYPE_COLOR_BALANCE_CONFIG, NULL);
*config = G_OBJECT (cb_tool->config);
g_signal_connect_object (cb_tool->config, "notify",
G_CALLBACK (color_balance_config_notify),
G_OBJECT (cb_tool), 0);
gegl_node_set (node,
"config", cb_tool->config,
NULL);
......@@ -206,7 +208,8 @@ gimp_color_balance_tool_map (GimpImageMapTool *image_map_tool)
/**************************/
static GtkAdjustment *
create_levels_scale (const gchar *left,
create_levels_scale (gdouble value,
const gchar *left,
const gchar *right,
GtkWidget *table,
gint col)
......@@ -223,7 +226,8 @@ create_levels_scale (const gchar *left,
gtk_widget_show (label);
spinbutton = gimp_spin_button_new (&adj,
0, -100.0, 100.0, 1.0, 10.0, 0.0, 1.0, 0);
value, -100.0, 100.0,
1.0, 10.0, 0.0, 1.0, 0);
slider = gtk_hscale_new (GTK_ADJUSTMENT (adj));
gtk_scale_set_draw_value (GTK_SCALE (slider), FALSE);
......@@ -248,18 +252,21 @@ create_levels_scale (const gchar *left,
static void
gimp_color_balance_tool_dialog (GimpImageMapTool *im_tool)
{
GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (im_tool);
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *table;
GtkWidget *button;
GtkWidget *frame;
GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (im_tool);
GimpColorBalanceConfig *config = cb_tool->config;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *table;
GtkWidget *button;
GtkWidget *frame;
frame = gimp_enum_radio_frame_new (GIMP_TYPE_TRANSFER_MODE,
gtk_label_new (_("Select Range to Adjust")),
G_CALLBACK (color_balance_range_callback),
cb_tool,
&cb_tool->range_radio);
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (cb_tool->range_radio),
config->range);
gtk_box_pack_start (GTK_BOX (im_tool->main_vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
......@@ -278,22 +285,28 @@ gimp_color_balance_tool_dialog (GimpImageMapTool *im_tool)
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
gtk_widget_show (table);
cb_tool->cyan_red_adj = create_levels_scale (_("Cyan"), _("Red"),
table, 0);
cb_tool->cyan_red_adj =
create_levels_scale (config->cyan_red[config->range] * 100.0,
_("Cyan"), _("Red"),
table, 0);
g_signal_connect (cb_tool->cyan_red_adj, "value-changed",
G_CALLBACK (color_balance_cr_changed),
cb_tool);
cb_tool->magenta_green_adj = create_levels_scale (_("Magenta"), _("Green"),
table, 1);
cb_tool->magenta_green_adj =
create_levels_scale (config->magenta_green[config->range] * 100.0,
_("Magenta"), _("Green"),
table, 1);
g_signal_connect (cb_tool->magenta_green_adj, "value-changed",
G_CALLBACK (color_balance_mg_changed),
cb_tool);
cb_tool->yellow_blue_adj = create_levels_scale (_("Yellow"), _("Blue"),
table, 2);
cb_tool->yellow_blue_adj =
create_levels_scale (config->yellow_blue[config->range] * 100.0,
_("Yellow"), _("Blue"),
table, 2);
g_signal_connect (cb_tool->yellow_blue_adj, "value-changed",
G_CALLBACK (color_balance_yb_changed),
......@@ -314,7 +327,7 @@ gimp_color_balance_tool_dialog (GimpImageMapTool *im_tool)
cb_tool->preserve_toggle =
gtk_check_button_new_with_mnemonic (_("Preserve _luminosity"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb_tool->preserve_toggle),
cb_tool->config->preserve_luminosity);
config->preserve_luminosity);
gtk_box_pack_end (GTK_BOX (im_tool->main_vbox), cb_tool->preserve_toggle,
FALSE, FALSE, 0);
gtk_widget_show (cb_tool->preserve_toggle);
......@@ -330,28 +343,53 @@ gimp_color_balance_tool_reset (GimpImageMapTool *im_tool)
GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (im_tool);
GimpTransferMode range = cb_tool->config->range;
g_object_freeze_notify (G_OBJECT (cb_tool->config));
gimp_config_reset (GIMP_CONFIG (cb_tool->config));
g_object_set (cb_tool->config,
"range", range,
NULL);
color_balance_update (cb_tool);
g_object_thaw_notify (G_OBJECT (cb_tool->config));
}
static void
color_balance_update (GimpColorBalanceTool *cb_tool)
color_balance_config_notify (GObject *object,
GParamSpec *pspec,
GimpColorBalanceTool *cb_tool)
{
GimpColorBalanceConfig *config = cb_tool->config;
GimpColorBalanceConfig *config = GIMP_COLOR_BALANCE_CONFIG (object);
gtk_adjustment_set_value (cb_tool->cyan_red_adj,
config->cyan_red[config->range] * 100.0);
gtk_adjustment_set_value (cb_tool->magenta_green_adj,
config->magenta_green[config->range] * 100.0);
gtk_adjustment_set_value (cb_tool->yellow_blue_adj,
config->yellow_blue[config->range] * 100.0);
if (! cb_tool->cyan_red_adj)
return;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb_tool->preserve_toggle),
config->preserve_luminosity);
if (! strcmp (pspec->name, "range"))
{
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (cb_tool->range_radio),
config->range);
}
else if (! strcmp (pspec->name, "cyan-red"))
{
gtk_adjustment_set_value (cb_tool->cyan_red_adj,
config->cyan_red[config->range] * 100.0);
}
else if (! strcmp (pspec->name, "magenta-green"))
{
gtk_adjustment_set_value (cb_tool->magenta_green_adj,
config->magenta_green[config->range] * 100.0);
}
else if (! strcmp (pspec->name, "yellow-blue"))
{
gtk_adjustment_set_value (cb_tool->yellow_blue_adj,
config->yellow_blue[config->range] * 100.0);
}
else if (! strcmp (pspec->name, "preserve-luminosity"))
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb_tool->preserve_toggle),
config->preserve_luminosity);
}
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (cb_tool));
}
static void
......@@ -366,8 +404,6 @@ color_balance_range_callback (GtkWidget *widget,
g_object_set (cb_tool->config,
"range", range,
NULL);
color_balance_update (cb_tool);
}
}
......@@ -376,10 +412,6 @@ color_balance_range_reset_callback (GtkWidget *widget,
GimpColorBalanceTool *cb_tool)
{
gimp_color_balance_config_reset_range (cb_tool->config);
color_balance_update (cb_tool);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (cb_tool));
}
static void
......@@ -394,8 +426,6 @@ color_balance_preserve_toggled (GtkWidget *widget,
g_object_set (config,
"preserve-luminosity", active,
NULL);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (cb_tool));
}
}
......@@ -411,8 +441,6 @@ color_balance_cr_changed (GtkAdjustment *adjustment,
g_object_set (config,
"cyan-red", value,
NULL);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (cb_tool));
}
}
......@@ -428,8 +456,6 @@ color_balance_mg_changed (GtkAdjustment *adjustment,
g_object_set (config,
"magenta-green", value,
NULL);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (cb_tool));
}
}
......@@ -445,7 +471,5 @@ color_balance_yb_changed (GtkAdjustment *adjustment,
g_object_set (config,
"yellow-blue", value,
NULL);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (cb_tool));
}
}
......@@ -18,6 +18,8 @@
#include "config.h"
#include <string.h>
#include <gegl.h>
#include <gtk/gtk.h>
......@@ -54,12 +56,15 @@ static gboolean gimp_colorize_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error);
static GeglNode * gimp_colorize_tool_get_operation (GimpImageMapTool *im_tool);
static GeglNode * gimp_colorize_tool_get_operation (GimpImageMapTool *im_tool,
GObject **config);
static void gimp_colorize_tool_map (GimpImageMapTool *im_tool);
static void gimp_colorize_tool_dialog (GimpImageMapTool *im_tool);
static void gimp_colorize_tool_reset (GimpImageMapTool *im_tool);
static void colorize_update_sliders (GimpColorizeTool *col_tool);
static void gimp_colorize_tool_config_notify (GObject *object,
GParamSpec *pspec,
GimpColorizeTool *col_tool);
static void colorize_hue_changed (GtkAdjustment *adj,
GimpColorizeTool *col_tool);
static void colorize_saturation_changed (GtkAdjustment *adj,
......@@ -105,7 +110,6 @@ gimp_colorize_tool_class_init (GimpColorizeToolClass *klass)
im_tool_class->get_operation = gimp_colorize_tool_get_operation;
im_tool_class->map = gimp_colorize_tool_map;
im_tool_class->dialog = gimp_colorize_tool_dialog;
im_tool_class->reset = gimp_colorize_tool_reset;
}
static void
......@@ -126,12 +130,6 @@ gimp_colorize_tool_finalize (GObject *object)
{
GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (object);
if (col_tool->config)
{
g_object_unref (col_tool->config);
col_tool->config = NULL;
}
g_slice_free (Colorize, col_tool->colorize);
G_OBJECT_CLASS (parent_class)->finalize (object);
......@@ -159,27 +157,32 @@ gimp_colorize_tool_initialize (GimpTool *tool,
GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
colorize_update_sliders (col_tool);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
return TRUE;
}
static GeglNode *
gimp_colorize_tool_get_operation (GimpImageMapTool *im_tool)
gimp_colorize_tool_get_operation (GimpImageMapTool *im_tool,
GObject **config)
{
GimpColorizeTool *tool = GIMP_COLORIZE_TOOL (im_tool);
GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (im_tool);
GeglNode *node;
node = g_object_new (GEGL_TYPE_NODE,
"operation", "gimp-colorize",
NULL);
tool->config = g_object_new (GIMP_TYPE_COLORIZE_CONFIG, NULL);
col_tool->config = g_object_new (GIMP_TYPE_COLORIZE_CONFIG, NULL);
*config = G_OBJECT (col_tool->config);
g_signal_connect_object (col_tool->config, "notify",
G_CALLBACK (gimp_colorize_tool_config_notify),
G_OBJECT (col_tool), 0);
gegl_node_set (node,
"config", tool->config,
"config", col_tool->config,
NULL);
return node;
......@@ -188,7 +191,7 @@ gimp_colorize_tool_get_operation (GimpImageMapTool *im_tool)
static void
gimp_colorize_tool_map (GimpImageMapTool *image_map_tool)
{
GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (image_map_tool);
GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (image_map_tool);
gimp_colorize_config_to_cruft (col_tool->config, col_tool->colorize);
}
......@@ -227,7 +230,8 @@ gimp_colorize_tool_dialog (GimpImageMapTool *image_map_tool)
/* Create the hue scale widget */
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
_("_Hue:"), SLIDER_WIDTH, -1,
0.0, 0.0, 360.0, 1.0, 15.0, 0,
col_tool->config->hue * 360.0,
0.0, 360.0, 1.0, 15.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
col_tool->hue_data = GTK_ADJUSTMENT (data);
......@@ -241,7 +245,8 @@ gimp_colorize_tool_dialog (GimpImageMapTool *image_map_tool)
/* Create the saturation scale widget */
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 1,
_("_Saturation:"), SLIDER_WIDTH, -1,
0.0, 0.0, 100.0, 1.0, 10.0, 0,
col_tool->config->saturation * 100.0,
0.0, 100.0, 1.0, 10.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
col_tool->saturation_data = GTK_ADJUSTMENT (data);
......@@ -255,7 +260,8 @@ gimp_colorize_tool_dialog (GimpImageMapTool *image_map_tool)
/* Create the lightness scale widget */
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 2,
_("_Lightness:"), SLIDER_WIDTH, -1,
0.0, -100.0, 100.0, 1.0, 10.0, 0,
col_tool->config->lightness * 100.0,
-100.0, 100.0, 1.0, 10.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
col_tool->lightness_data = GTK_ADJUSTMENT (data);
......@@ -268,24 +274,32 @@ gimp_colorize_tool_dialog (GimpImageMapTool *image_map_tool)
}
static void
gimp_colorize_tool_reset (GimpImageMapTool *image_map_tool)
gimp_colorize_tool_config_notify (GObject *object,
GParamSpec *pspec,
GimpColorizeTool *col_tool)
{
GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (image_map_tool);
GimpColorizeConfig *config = GIMP_COLORIZE_CONFIG (object);
gimp_config_reset (GIMP_CONFIG (col_tool->config));
if (! col_tool->hue_data)
return;
colorize_update_sliders (col_tool);
}
if (! strcmp (pspec->name, "hue"))
{
gtk_adjustment_set_value (col_tool->hue_data,
config->hue * 360.0);
}
else if (! strcmp (pspec->name, "saturation"))
{
gtk_adjustment_set_value (col_tool->saturation_data,
config->saturation * 100.0);
}
else if (! strcmp (pspec->name, "lightness"))
{
gtk_adjustment_set_value (col_tool->lightness_data,
config->lightness * 100.0);
}
static void
colorize_update_sliders (GimpColorizeTool *col_tool)
{
gtk_adjustment_set_value (col_tool->hue_data,
col_tool->config->hue * 360.0);
gtk_adjustment_set_value (col_tool->saturation_data,
col_tool->config->saturation * 100.0);
gtk_adjustment_set_value (col_tool->lightness_data,
col_tool->config->lightness * 100.0);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (col_tool));
}
static void
......@@ -299,8 +313,6 @@ colorize_hue_changed (GtkAdjustment *adjustment,
g_object_set (col_tool->config,
"hue", value,
NULL);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (col_tool));
}
}
......@@ -315,8 +327,6 @@ colorize_saturation_changed (GtkAdjustment *adjustment,
g_object_set (col_tool->config,
"saturation", value,
NULL);