gimp r24752 - in trunk: . app/tools
- From: mitch svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r24752 - in trunk: . app/tools
- Date: Wed, 30 Jan 2008 18:31:44 +0000 (GMT)
Author: mitch
Date: Wed Jan 30 18:31:43 2008
New Revision: 24752
URL: http://svn.gnome.org/viewvc/gimp?rev=24752&view=rev
Log:
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().
Modified:
trunk/ChangeLog
trunk/app/tools/gimpbrightnesscontrasttool.c
trunk/app/tools/gimpcolorbalancetool.c
trunk/app/tools/gimpcolorizetool.c
trunk/app/tools/gimpcurvestool.c
trunk/app/tools/gimphuesaturationtool.c
trunk/app/tools/gimpimagemaptool.c
trunk/app/tools/gimpimagemaptool.h
trunk/app/tools/gimplevelstool.c
trunk/app/tools/gimpposterizetool.c
trunk/app/tools/gimpthresholdtool.c
Modified: trunk/app/tools/gimpbrightnesscontrasttool.c
==============================================================================
--- trunk/app/tools/gimpbrightnesscontrasttool.c (original)
+++ trunk/app/tools/gimpbrightnesscontrasttool.c Wed Jan 30 18:31:43 2008
@@ -18,6 +18,8 @@
#include "config.h"
+#include <string.h>
+
#include <gegl.h>
#include <gtk/gtk.h>
@@ -72,12 +74,15 @@
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 @@
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 @@
{
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_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 @@
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 @@
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 @@
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 @@
/* 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 @@
/* 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 @@
}
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 @@
g_object_set (config,
"brightness", value,
NULL);
-
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (bc_tool));
}
}
@@ -379,7 +384,5 @@
g_object_set (config,
"contrast", value,
NULL);
-
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (bc_tool));
}
}
Modified: trunk/app/tools/gimpcolorbalancetool.c
==============================================================================
--- trunk/app/tools/gimpcolorbalancetool.c (original)
+++ trunk/app/tools/gimpcolorbalancetool.c Wed Jan 30 18:31:43 2008
@@ -18,6 +18,8 @@
#include "config.h"
+#include <string.h>
+
#include <gegl.h>
#include <gtk/gtk.h>
@@ -51,12 +53,16 @@
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 @@
{
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_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 @@
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 @@
/**************************/
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
g_object_set (cb_tool->config,
"range", range,
NULL);
-
- color_balance_update (cb_tool);
}
}
@@ -376,10 +412,6 @@
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 @@
g_object_set (config,
"preserve-luminosity", active,
NULL);
-
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (cb_tool));
}
}
@@ -411,8 +441,6 @@
g_object_set (config,
"cyan-red", value,
NULL);
-
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (cb_tool));
}
}
@@ -428,8 +456,6 @@
g_object_set (config,
"magenta-green", value,
NULL);
-
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (cb_tool));
}
}
@@ -445,7 +471,5 @@
g_object_set (config,
"yellow-blue", value,
NULL);
-
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (cb_tool));
}
}
Modified: trunk/app/tools/gimpcolorizetool.c
==============================================================================
--- trunk/app/tools/gimpcolorizetool.c (original)
+++ trunk/app/tools/gimpcolorizetool.c Wed Jan 30 18:31:43 2008
@@ -18,6 +18,8 @@
#include "config.h"
+#include <string.h>
+
#include <gegl.h>
#include <gtk/gtk.h>
@@ -54,12 +56,15 @@
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 @@
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 @@
{
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_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 @@
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 @@
/* 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 @@
/* 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 @@
/* 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 @@
}
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 @@
g_object_set (col_tool->config,
"hue", value,
NULL);
-
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (col_tool));
}
}
@@ -315,8 +327,6 @@
g_object_set (col_tool->config,
"saturation", value,
NULL);
-
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (col_tool));
}
}
@@ -331,7 +341,5 @@
g_object_set (col_tool->config,
"lightness", value,
NULL);
-
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (col_tool));
}
}
Modified: trunk/app/tools/gimpcurvestool.c
==============================================================================
--- trunk/app/tools/gimpcurvestool.c (original)
+++ trunk/app/tools/gimpcurvestool.c Wed Jan 30 18:31:43 2008
@@ -84,7 +84,8 @@
GimpImageType sample_type,
GimpRGB *color,
gint color_index);
-static GeglNode * gimp_curves_tool_get_operation (GimpImageMapTool *image_map_tool);
+static GeglNode * gimp_curves_tool_get_operation (GimpImageMapTool *image_map_tool,
+ GObject **config);
static void gimp_curves_tool_map (GimpImageMapTool *image_map_tool);
static void gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool);
static void gimp_curves_tool_reset (GimpImageMapTool *image_map_tool);
@@ -94,8 +95,10 @@
static gboolean gimp_curves_tool_settings_save (GimpImageMapTool *image_map_tool,
gpointer fp);
-static void curves_curve_callback (GimpCurve *curve,
+static void gimp_curves_tool_config_notify (GObject *object,
+ GParamSpec *pspec,
GimpCurvesTool *tool);
+
static void curves_channel_callback (GtkWidget *widget,
GimpCurvesTool *tool);
static void curves_channel_reset_callback (GtkWidget *widget,
@@ -187,12 +190,6 @@
{
GimpCurvesTool *tool = GIMP_CURVES_TOOL (object);
- if (tool->config)
- {
- g_object_unref (tool->config);
- tool->config = NULL;
- }
-
gimp_lut_free (tool->lut);
if (tool->hist)
@@ -381,11 +378,11 @@
}
static GeglNode *
-gimp_curves_tool_get_operation (GimpImageMapTool *image_map_tool)
+gimp_curves_tool_get_operation (GimpImageMapTool *image_map_tool,
+ GObject **config)
{
GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool);
GeglNode *node;
- gint i;
node = g_object_new (GEGL_TYPE_NODE,
"operation", "gimp-curves",
@@ -393,12 +390,11 @@
tool->config = g_object_new (GIMP_TYPE_CURVES_CONFIG, NULL);
- for (i = 0; i < G_N_ELEMENTS (tool->config->curve); i++)
- {
- g_signal_connect_object (tool->config->curve[i], "dirty",
- G_CALLBACK (curves_curve_callback),
- tool, 0);
- }
+ *config = G_OBJECT (tool->config);
+
+ g_signal_connect_object (tool->config, "notify",
+ G_CALLBACK (gimp_curves_tool_config_notify),
+ tool, 0);
gegl_node_set (node,
"config", tool->config,
@@ -622,15 +618,7 @@
{
GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool);
- if (gimp_curves_config_load_cruft (tool->config, fp, error))
- {
- gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (tool->curve_type),
- GIMP_CURVE_SMOOTH);
-
- return TRUE;
- }
-
- return FALSE;
+ return gimp_curves_config_load_cruft (tool->config, fp, error);
}
static gboolean
@@ -643,15 +631,16 @@
}
static void
-curves_curve_callback (GimpCurve *curve,
- GimpCurvesTool *tool)
+gimp_curves_tool_config_notify (GObject *object,
+ GParamSpec *pspec,
+ GimpCurvesTool *tool)
{
- GimpCurvesConfig *config = tool->config;
+ GimpCurvesConfig *config = GIMP_CURVES_CONFIG (object);
- if (curve != config->curve[config->channel])
+ if (! tool->xrange)
return;
- if (tool->xrange)
+ if (! strcmp (pspec->name, "channel"))
{
switch (config->channel)
{
@@ -673,25 +662,6 @@
config->curve[GIMP_HISTOGRAM_BLUE]->curve);
break;
}
- }
-
- if (GIMP_IMAGE_MAP_TOOL (tool)->drawable)
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
-}
-
-static void
-curves_channel_callback (GtkWidget *widget,
- GimpCurvesTool *tool)
-{
- gint value;
-
- if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value))
- {
- GimpCurvesConfig *config = tool->config;
-
- g_object_set (config,
- "channel", value,
- NULL);
gimp_histogram_view_set_channel (GIMP_HISTOGRAM_VIEW (tool->graph),
config->channel);
@@ -703,11 +673,29 @@
gimp_curve_view_set_curve (GIMP_CURVE_VIEW (tool->graph),
config->curve[config->channel]);
-
+ }
+ else if (! strcmp (pspec->name, "curve"))
+ {
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (tool->curve_type),
config->curve[config->channel]->curve_type);
+ }
+
+ gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
+}
- curves_curve_callback (config->curve[config->channel], tool);
+static void
+curves_channel_callback (GtkWidget *widget,
+ GimpCurvesTool *tool)
+{
+ GimpCurvesConfig *config = tool->config;
+ gint value;
+
+ if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value) &&
+ config->channel != value)
+ {
+ g_object_set (config,
+ "channel", value,
+ NULL);
}
}
Modified: trunk/app/tools/gimphuesaturationtool.c
==============================================================================
--- trunk/app/tools/gimphuesaturationtool.c (original)
+++ trunk/app/tools/gimphuesaturationtool.c Wed Jan 30 18:31:43 2008
@@ -18,6 +18,8 @@
#include "config.h"
+#include <string.h>
+
#include <gegl.h>
#include <gtk/gtk.h>
@@ -57,12 +59,16 @@
GimpDisplay *display,
GError **error);
-static GeglNode * gimp_hue_saturation_tool_get_operation (GimpImageMapTool *im_tool);
+static GeglNode * gimp_hue_saturation_tool_get_operation (GimpImageMapTool *im_tool,
+ GObject **config);
static void gimp_hue_saturation_tool_map (GimpImageMapTool *im_tool);
static void gimp_hue_saturation_tool_dialog (GimpImageMapTool *im_tool);
static void gimp_hue_saturation_tool_reset (GimpImageMapTool *im_tool);
-static void hue_saturation_update_sliders (GimpHueSaturationTool *hs_tool);
+static void hue_saturation_config_notify (GObject *object,
+ GParamSpec *pspec,
+ GimpHueSaturationTool *hs_tool);
+
static void hue_saturation_update_color_areas (GimpHueSaturationTool *hs_tool);
static void hue_saturation_range_callback (GtkWidget *widget,
@@ -138,12 +144,6 @@
{
GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (object);
- if (hs_tool->config)
- {
- g_object_unref (hs_tool->config);
- hs_tool->config = NULL;
- }
-
g_slice_free (HueSaturation, hs_tool->hue_saturation);
G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -173,17 +173,12 @@
GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
- gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (hs_tool->range_radio),
- hs_tool->config->range);
-
- hue_saturation_update_sliders (hs_tool);
- hue_saturation_update_color_areas (hs_tool);
-
return TRUE;
}
static GeglNode *
-gimp_hue_saturation_tool_get_operation (GimpImageMapTool *im_tool)
+gimp_hue_saturation_tool_get_operation (GimpImageMapTool *im_tool,
+ GObject **config)
{
GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (im_tool);
GeglNode *node;
@@ -194,6 +189,12 @@
hs_tool->config = g_object_new (GIMP_TYPE_HUE_SATURATION_CONFIG, NULL);
+ *config = G_OBJECT (hs_tool->config);
+
+ g_signal_connect_object (hs_tool->config, "notify",
+ G_CALLBACK (hue_saturation_config_notify),
+ G_OBJECT (hs_tool), 0);
+
gegl_node_set (node,
"config", hs_tool->config,
NULL);
@@ -217,19 +218,20 @@
static void
gimp_hue_saturation_tool_dialog (GimpImageMapTool *image_map_tool)
{
- GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (image_map_tool);
- GtkWidget *vbox;
- GtkWidget *abox;
- GtkWidget *table;
- GtkWidget *slider;
- GtkWidget *button;
- GtkWidget *frame;
- GtkWidget *hbox;
- GtkObject *data;
- GtkSizeGroup *label_group;
- GtkSizeGroup *spinner_group;
- GSList *group = NULL;
- gint i;
+ GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (image_map_tool);
+ GimpHueSaturationConfig *config = hs_tool->config;
+ GtkWidget *vbox;
+ GtkWidget *abox;
+ GtkWidget *table;
+ GtkWidget *slider;
+ GtkWidget *button;
+ GtkWidget *frame;
+ GtkWidget *hbox;
+ GtkObject *data;
+ GtkSizeGroup *label_group;
+ GtkSizeGroup *spinner_group;
+ GSList *group = NULL;
+ gint i;
const struct
{
@@ -343,7 +345,8 @@
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
_("_Overlap:"), SLIDER_WIDTH, -1,
- 0.0, 0, 100.0, 1.0, 15.0, 0,
+ config->overlap * 100.0,
+ 0.0, 100.0, 1.0, 15.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
hs_tool->overlap_data = GTK_ADJUSTMENT (data);
@@ -379,7 +382,8 @@
/* Create the hue scale widget */
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
_("_Hue:"), SLIDER_WIDTH, -1,
- 0.0, -180.0, 180.0, 1.0, 15.0, 0,
+ config->hue[config->range] * 180.0,
+ -180.0, 180.0, 1.0, 15.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
hs_tool->hue_data = GTK_ADJUSTMENT (data);
@@ -397,7 +401,8 @@
/* Create the lightness scale widget */
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 1,
_("_Lightness:"), SLIDER_WIDTH, -1,
- 0.0, -100.0, 100.0, 1.0, 10.0, 0,
+ config->lightness[config->range] * 100.0,
+ -100.0, 100.0, 1.0, 10.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
hs_tool->lightness_data = GTK_ADJUSTMENT (data);
@@ -415,7 +420,8 @@
/* Create the saturation scale widget */
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 2,
_("_Saturation:"), SLIDER_WIDTH, -1,
- 0.0, -100.0, 100.0, 1.0, 10.0, 0,
+ config->saturation[config->range] * 100.0,
+ -100.0, 100.0, 1.0, 10.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
hs_tool->saturation_data = GTK_ADJUSTMENT (data);
@@ -441,6 +447,11 @@
g_signal_connect (button, "clicked",
G_CALLBACK (hue_saturation_range_reset_callback),
hs_tool);
+
+ gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (hs_tool->range_radio),
+ config->range);
+
+ hue_saturation_update_color_areas (hs_tool);
}
static void
@@ -449,28 +460,55 @@
GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (image_map_tool);
GimpHueRange range = hs_tool->config->range;
+ g_object_freeze_notify (G_OBJECT (hs_tool->config));
+
gimp_config_reset (GIMP_CONFIG (hs_tool->config));
g_object_set (hs_tool->config,
"range", range,
NULL);
- hue_saturation_update_sliders (hs_tool);
- hue_saturation_update_color_areas (hs_tool);
+ g_object_thaw_notify (G_OBJECT (hs_tool->config));
}
static void
-hue_saturation_update_sliders (GimpHueSaturationTool *hs_tool)
+hue_saturation_config_notify (GObject *object,
+ GParamSpec *pspec,
+ GimpHueSaturationTool *hs_tool)
{
- GimpHueSaturationConfig *config = hs_tool->config;
+ GimpHueSaturationConfig *config = GIMP_HUE_SATURATION_CONFIG (object);
+
+ if (! hs_tool->hue_data)
+ return;
+
+ if (! strcmp (pspec->name, "range"))
+ {
+ gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (hs_tool->range_radio),
+ config->range);
+ }
+ else if (! strcmp (pspec->name, "hue"))
+ {
+ gtk_adjustment_set_value (hs_tool->hue_data,
+ config->hue[config->range] * 180.0);
+ }
+ else if (! strcmp (pspec->name, "lightness"))
+ {
+ gtk_adjustment_set_value (hs_tool->lightness_data,
+ config->lightness[config->range] * 100.0);
+ }
+ else if (! strcmp (pspec->name, "saturation"))
+ {
+ gtk_adjustment_set_value (hs_tool->saturation_data,
+ config->saturation[config->range] * 100.0);
+ }
+ else if (! strcmp (pspec->name, "overlap"))
+ {
+ gtk_adjustment_set_value (hs_tool->overlap_data,
+ config->overlap * 100.0);
+ }
+
+ hue_saturation_update_color_areas (hs_tool);
- gtk_adjustment_set_value (hs_tool->hue_data,
- config->hue[config->range] * 180.0);
- gtk_adjustment_set_value (hs_tool->lightness_data,
- config->lightness[config->range] * 100.0);
- gtk_adjustment_set_value (hs_tool->saturation_data,
- config->saturation[config->range] * 100.0);
- gtk_adjustment_set_value (hs_tool->overlap_data,
- config->overlap * 100.0);
+ gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (hs_tool));
}
static void
@@ -512,8 +550,6 @@
g_object_set (hs_tool->config,
"range", range,
NULL);
-
- hue_saturation_update_sliders (hs_tool);
}
}
@@ -522,11 +558,6 @@
GimpHueSaturationTool *hs_tool)
{
gimp_hue_saturation_config_reset_range (hs_tool->config);
-
- hue_saturation_update_sliders (hs_tool);
- hue_saturation_update_color_areas (hs_tool);
-
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (hs_tool));
}
static void
@@ -541,10 +572,6 @@
g_object_set (config,
"hue", value,
NULL);
-
- hue_saturation_update_color_areas (hs_tool);
-
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (hs_tool));
}
}
@@ -560,10 +587,6 @@
g_object_set (config,
"lightness", value,
NULL);
-
- hue_saturation_update_color_areas (hs_tool);
-
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (hs_tool));
}
}
@@ -579,10 +602,6 @@
g_object_set (config,
"saturation", value,
NULL);
-
- hue_saturation_update_color_areas (hs_tool);
-
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (hs_tool));
}
}
@@ -598,9 +617,5 @@
g_object_set (config,
"overlap", value,
NULL);
-
- hue_saturation_update_color_areas (hs_tool);
-
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (hs_tool));
}
}
Modified: trunk/app/tools/gimpimagemaptool.c
==============================================================================
--- trunk/app/tools/gimpimagemaptool.c (original)
+++ trunk/app/tools/gimpimagemaptool.c Wed Jan 30 18:31:43 2008
@@ -26,6 +26,7 @@
#include <gdk/gdkkeysyms.h>
#include "libgimpbase/gimpbase.h"
+#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"
@@ -163,6 +164,7 @@
image_map_tool->drawable = NULL;
image_map_tool->operation = NULL;
+ image_map_tool->config = NULL;
image_map_tool->image_map = NULL;
image_map_tool->shell = NULL;
@@ -187,7 +189,8 @@
klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (image_map_tool);
if (klass->get_operation)
- image_map_tool->operation = klass->get_operation (image_map_tool);
+ image_map_tool->operation = klass->get_operation (image_map_tool,
+ &image_map_tool->config);
return object;
}
@@ -203,6 +206,12 @@
image_map_tool->operation = NULL;
}
+ if (image_map_tool->config)
+ {
+ g_object_unref (image_map_tool->config);
+ image_map_tool->config = NULL;
+ }
+
if (image_map_tool->shell)
{
gtk_widget_destroy (image_map_tool->shell);
@@ -480,7 +489,14 @@
static void
gimp_image_map_tool_reset (GimpImageMapTool *tool)
{
- GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->reset (tool);
+ if (GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->reset)
+ {
+ GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->reset (tool);
+ }
+ else if (tool->config)
+ {
+ gimp_config_reset (GIMP_CONFIG (tool->config));
+ }
}
static void
Modified: trunk/app/tools/gimpimagemaptool.h
==============================================================================
--- trunk/app/tools/gimpimagemaptool.h (original)
+++ trunk/app/tools/gimpimagemaptool.h Wed Jan 30 18:31:43 2008
@@ -42,6 +42,7 @@
GimpDrawable *drawable;
GeglNode *operation;
+ GObject *config;
GimpImageMapApplyFunc apply_func;
gpointer apply_data;
@@ -69,7 +70,8 @@
const gchar *save_dialog_title;
/* virtual functions */
- GeglNode * (* get_operation) (GimpImageMapTool *image_map_tool);
+ GeglNode * (* get_operation) (GimpImageMapTool *image_map_tool,
+ GObject **config);
void (* map) (GimpImageMapTool *image_map_tool);
void (* dialog) (GimpImageMapTool *image_map_tool);
void (* reset) (GimpImageMapTool *image_map_tool);
Modified: trunk/app/tools/gimplevelstool.c
==============================================================================
--- trunk/app/tools/gimplevelstool.c (original)
+++ trunk/app/tools/gimplevelstool.c Wed Jan 30 18:31:43 2008
@@ -75,7 +75,8 @@
GimpRGB *color,
gint color_index);
-static GeglNode * gimp_levels_tool_get_operation (GimpImageMapTool *im_tool);
+static GeglNode * gimp_levels_tool_get_operation (GimpImageMapTool *im_tool,
+ GObject **config);
static void gimp_levels_tool_map (GimpImageMapTool *im_tool);
static void gimp_levels_tool_dialog (GimpImageMapTool *im_tool);
static void gimp_levels_tool_dialog_unmap (GtkWidget *dialog,
@@ -87,7 +88,10 @@
static gboolean gimp_levels_tool_settings_save (GimpImageMapTool *im_tool,
gpointer fp);
-static void levels_update_adjustments (GimpLevelsTool *tool);
+static void gimp_levels_tool_config_notify (GObject *object,
+ GParamSpec *pspec,
+ GimpLevelsTool *tool);
+
static void levels_update_input_bar (GimpLevelsTool *tool);
static void levels_channel_callback (GtkWidget *widget,
@@ -185,12 +189,6 @@
{
GimpLevelsTool *tool = GIMP_LEVELS_TOOL (object);
- if (tool->config)
- {
- g_object_unref (tool->config);
- tool->config = NULL;
- }
-
gimp_lut_free (tool->lut);
if (tool->hist)
@@ -237,11 +235,6 @@
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->config->channel);
-
- levels_update_adjustments (l_tool);
-
gimp_drawable_calculate_histogram (drawable, l_tool->hist);
gimp_histogram_view_set_histogram (GIMP_HISTOGRAM_VIEW (l_tool->hist_view),
l_tool->hist);
@@ -250,7 +243,8 @@
}
static GeglNode *
-gimp_levels_tool_get_operation (GimpImageMapTool *im_tool)
+gimp_levels_tool_get_operation (GimpImageMapTool *im_tool,
+ GObject **config)
{
GimpLevelsTool *tool = GIMP_LEVELS_TOOL (im_tool);
GeglNode *node;
@@ -261,6 +255,12 @@
tool->config = g_object_new (GIMP_TYPE_LEVELS_CONFIG, NULL);
+ *config = G_OBJECT (tool->config);
+
+ g_signal_connect_object (tool->config, "notify",
+ G_CALLBACK (gimp_levels_tool_config_notify),
+ G_OBJECT (tool), 0);
+
gegl_node_set (node,
"config", tool->config,
NULL);
@@ -337,23 +337,24 @@
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;
+ GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool);
+ GimpToolOptions *tool_options = GIMP_TOOL_GET_OPTIONS (image_map_tool);
+ GimpLevelsConfig *config = tool->config;
+ 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;
/* The option menu for selecting channels */
hbox = gtk_hbox_new (FALSE, 6);
@@ -483,7 +484,9 @@
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);
+ spinbutton = gimp_spin_button_new (&data,
+ config->low_input[config->channel] * 255.0,
+ 0, 255, 1, 10, 10, 0.5, 0);
gtk_box_pack_start (GTK_BOX (hbox2), spinbutton, FALSE, FALSE, 0);
gtk_widget_show (spinbutton);
@@ -496,7 +499,9 @@
tool->low_input);
/* input gamma spin */
- spinbutton = gimp_spin_button_new (&data, 1, 0.1, 10, 0.01, 0.1, 1, 0.5, 2);
+ spinbutton = gimp_spin_button_new (&data,
+ config->gamma[config->channel],
+ 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);
@@ -525,7 +530,9 @@
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);
+ spinbutton = gimp_spin_button_new (&data,
+ config->high_input[config->channel] * 255.0,
+ 0, 255, 1, 10, 10, 0.5, 0);
gtk_box_pack_start (GTK_BOX (hbox2), spinbutton, FALSE, FALSE, 0);
gtk_widget_show (spinbutton);
@@ -585,7 +592,9 @@
gtk_widget_show (hbox);
/* low output spin */
- spinbutton = gimp_spin_button_new (&data, 0, 0, 255, 1, 10, 10, 0.5, 0);
+ spinbutton = gimp_spin_button_new (&data,
+ config->low_output[config->channel] * 255.0,
+ 0, 255, 1, 10, 10, 0.5, 0);
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
gtk_widget_show (spinbutton);
@@ -598,7 +607,9 @@
tool->low_output);
/* high output spin */
- spinbutton = gimp_spin_button_new (&data, 255, 0, 255, 1, 10, 10, 0.5, 0);
+ spinbutton = gimp_spin_button_new (&data,
+ config->high_output[config->channel] * 255.0,
+ 0, 255, 1, 10, 10, 0.5, 0);
gtk_box_pack_end (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
gtk_widget_show (spinbutton);
@@ -665,6 +676,9 @@
g_signal_connect (image_map_tool->shell, "unmap",
G_CALLBACK (gimp_levels_tool_dialog_unmap),
tool);
+
+ gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (tool->channel_menu),
+ config->channel);
}
static void
@@ -682,12 +696,14 @@
GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool);
GimpHistogramChannel channel = tool->config->channel;
+ g_object_freeze_notify (G_OBJECT (tool->config));
+
gimp_config_reset (GIMP_CONFIG (tool->config));
g_object_set (tool->config,
"channel", channel,
NULL);
- levels_update_adjustments (tool);
+ g_object_thaw_notify (G_OBJECT (tool->config));
}
static gboolean
@@ -697,14 +713,7 @@
{
GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool);
- if (gimp_levels_config_load_cruft (tool->config, fp, error))
- {
- levels_update_adjustments (tool);
-
- return TRUE;
- }
-
- return FALSE;
+ return gimp_levels_config_load_cruft (tool->config, fp, error);
}
static gboolean
@@ -717,36 +726,62 @@
}
static void
-levels_update_adjustments (GimpLevelsTool *tool)
+gimp_levels_tool_config_notify (GObject *object,
+ GParamSpec *pspec,
+ GimpLevelsTool *tool)
{
- GimpLevelsConfig *config = tool->config;
+ GimpLevelsConfig *config = GIMP_LEVELS_CONFIG (object);
- tool->low_input->upper = 255;
- tool->high_input->lower = 0;
- tool->gamma_linear->lower = 0;
- tool->gamma_linear->upper = 255;
-
- gtk_adjustment_set_value (tool->low_input,
- config->low_input[config->channel] * 255.0);
- gtk_adjustment_set_value (tool->gamma,
- config->gamma[config->channel]);
- gtk_adjustment_set_value (tool->high_input,
- config->high_input[config->channel] * 255.0);
-
- tool->low_input->upper = tool->high_input->value;
- tool->high_input->lower = tool->low_input->value;
- tool->gamma_linear->lower = tool->low_input->value;
- tool->gamma_linear->upper = tool->high_input->value;
- gtk_adjustment_changed (tool->low_input);
- gtk_adjustment_changed (tool->high_input);
- gtk_adjustment_changed (tool->gamma_linear);
+ if (! tool->low_input)
+ return;
- gtk_adjustment_set_value (tool->low_output,
- config->low_output[config->channel] * 255.0);
- gtk_adjustment_set_value (tool->high_output,
- config->high_output[config->channel] * 255.0);
+ if (! strcmp (pspec->name, "channel"))
+ {
+ gimp_histogram_view_set_channel (GIMP_HISTOGRAM_VIEW (tool->hist_view),
+ config->channel);
+ gimp_color_bar_set_channel (GIMP_COLOR_BAR (tool->output_bar),
+ config->channel);
+ gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (tool->channel_menu),
+ config->channel);
+ }
+ else if (! strcmp (pspec->name, "gamma") ||
+ ! strcmp (pspec->name, "low-input") ||
+ ! strcmp (pspec->name, "high-input"))
+ {
+ tool->low_input->upper = 255;
+ tool->high_input->lower = 0;
+ tool->gamma_linear->lower = 0;
+ tool->gamma_linear->upper = 255;
+
+ gtk_adjustment_set_value (tool->low_input,
+ config->low_input[config->channel] * 255.0);
+ gtk_adjustment_set_value (tool->gamma,
+ config->gamma[config->channel]);
+ gtk_adjustment_set_value (tool->high_input,
+ config->high_input[config->channel] * 255.0);
+
+ tool->low_input->upper = tool->high_input->value;
+ tool->high_input->lower = tool->low_input->value;
+ tool->gamma_linear->lower = tool->low_input->value;
+ tool->gamma_linear->upper = tool->high_input->value;
+ gtk_adjustment_changed (tool->low_input);
+ gtk_adjustment_changed (tool->high_input);
+ gtk_adjustment_changed (tool->gamma_linear);
- levels_update_input_bar (tool);
+ levels_update_input_bar (tool);
+ }
+ else if (! strcmp (pspec->name, "low-output"))
+ {
+ gtk_adjustment_set_value (tool->low_output,
+ config->low_output[config->channel] * 255.0);
+ }
+ else if (! strcmp (pspec->name, "high-output"))
+ {
+ gtk_adjustment_set_value (tool->high_output,
+ config->high_output[config->channel] * 255.0);
+ }
+
+ gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
}
static void
@@ -810,18 +845,12 @@
{
gint value;
- if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value))
+ if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value) &&
+ tool->config->channel != value)
{
g_object_set (tool->config,
"channel", value,
NULL);
-
- gimp_histogram_view_set_channel (GIMP_HISTOGRAM_VIEW (tool->hist_view),
- tool->config->channel);
- gimp_color_bar_set_channel (GIMP_COLOR_BAR (tool->output_bar),
- tool->config->channel);
-
- levels_update_adjustments (tool);
}
}
@@ -830,9 +859,6 @@
GimpLevelsTool *tool)
{
gimp_levels_config_reset_channel (tool->config);
- levels_update_adjustments (tool);
-
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
}
static gboolean
@@ -867,9 +893,6 @@
GimpLevelsTool *tool)
{
gimp_levels_config_stretch (tool->config, tool->hist, tool->color);
- levels_update_adjustments (tool);
-
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
}
static void
@@ -923,9 +946,6 @@
g_object_set (config,
"low-input", value / 255.0,
NULL);
- levels_update_input_bar (tool);
-
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
}
levels_linear_gamma_update (tool);
@@ -942,9 +962,6 @@
g_object_set (config,
"gamma", adjustment->value,
NULL);
- levels_update_input_bar (tool);
-
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
}
levels_linear_gamma_update (tool);
@@ -967,9 +984,6 @@
g_object_set (config,
"high-input", value / 255.0,
NULL);
- levels_update_input_bar (tool);
-
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
}
levels_linear_gamma_update (tool);
@@ -987,8 +1001,6 @@
g_object_set (config,
"low-output", value / 255.0,
NULL);
-
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
}
}
@@ -1004,8 +1016,6 @@
g_object_set (config,
"high-output", value / 255.0,
NULL);
-
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
}
}
@@ -1103,8 +1113,4 @@
levels_input_adjust_by_color (tool->config,
value, tool->config->channel, color);
}
-
- levels_update_adjustments (tool);
-
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
}
Modified: trunk/app/tools/gimpposterizetool.c
==============================================================================
--- trunk/app/tools/gimpposterizetool.c (original)
+++ trunk/app/tools/gimpposterizetool.c Wed Jan 30 18:31:43 2008
@@ -54,10 +54,14 @@
GimpDisplay *display,
GError **error);
-static GeglNode * gimp_posterize_tool_get_operation (GimpImageMapTool *im_tool);
+static GeglNode * gimp_posterize_tool_get_operation (GimpImageMapTool *im_tool,
+ GObject **config);
static void gimp_posterize_tool_map (GimpImageMapTool *im_tool);
static void gimp_posterize_tool_dialog (GimpImageMapTool *im_tool);
-static void gimp_posterize_tool_reset (GimpImageMapTool *im_tool);
+
+static void gimp_posterize_tool_config_notify (GObject *object,
+ GParamSpec *pspec,
+ GimpPosterizeTool *posterize_tool);
static void gimp_posterize_tool_levels_changed (GtkAdjustment *adjustment,
GimpPosterizeTool *posterize_tool);
@@ -101,7 +105,6 @@
im_tool_class->get_operation = gimp_posterize_tool_get_operation;
im_tool_class->map = gimp_posterize_tool_map;
im_tool_class->dialog = gimp_posterize_tool_dialog;
- im_tool_class->reset = gimp_posterize_tool_reset;
}
static void
@@ -120,12 +123,6 @@
{
GimpPosterizeTool *posterize_tool = GIMP_POSTERIZE_TOOL (object);
- if (posterize_tool->config)
- {
- g_object_unref (posterize_tool->config);
- posterize_tool->config = NULL;
- }
-
if (posterize_tool->lut)
{
gimp_lut_free (posterize_tool->lut);
@@ -168,7 +165,8 @@
}
static GeglNode *
-gimp_posterize_tool_get_operation (GimpImageMapTool *image_map_tool)
+gimp_posterize_tool_get_operation (GimpImageMapTool *image_map_tool,
+ GObject **config)
{
GimpPosterizeTool *posterize_tool = GIMP_POSTERIZE_TOOL (image_map_tool);
GeglNode *node;
@@ -179,6 +177,12 @@
posterize_tool->config = g_object_new (GIMP_TYPE_POSTERIZE_CONFIG, NULL);
+ *config = G_OBJECT (posterize_tool->config);
+
+ g_signal_connect_object (posterize_tool->config, "notify",
+ G_CALLBACK (gimp_posterize_tool_config_notify),
+ G_OBJECT (posterize_tool), 0);
+
gegl_node_set (node,
"config", posterize_tool->config,
NULL);
@@ -232,14 +236,18 @@
}
static void
-gimp_posterize_tool_reset (GimpImageMapTool *image_map_tool)
+gimp_posterize_tool_config_notify (GObject *object,
+ GParamSpec *pspec,
+ GimpPosterizeTool *posterize_tool)
{
- GimpPosterizeTool *posterize_tool = GIMP_POSTERIZE_TOOL (image_map_tool);
+ GimpPosterizeConfig *config = GIMP_POSTERIZE_CONFIG (object);
- gimp_config_reset (GIMP_CONFIG (posterize_tool->config));
+ if (! posterize_tool->levels_data)
+ return;
- gtk_adjustment_set_value (posterize_tool->levels_data,
- posterize_tool->config->levels);
+ gtk_adjustment_set_value (posterize_tool->levels_data, config->levels);
+
+ gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (posterize_tool));
}
static void
@@ -254,7 +262,5 @@
g_object_set (config,
"levels", value,
NULL);
-
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (posterize_tool));
}
}
Modified: trunk/app/tools/gimpthresholdtool.c
==============================================================================
--- trunk/app/tools/gimpthresholdtool.c (original)
+++ trunk/app/tools/gimpthresholdtool.c Wed Jan 30 18:31:43 2008
@@ -55,10 +55,14 @@
GimpDisplay *display,
GError **error);
-static GeglNode * gimp_threshold_tool_get_operation (GimpImageMapTool *im_tool);
+static GeglNode * gimp_threshold_tool_get_operation (GimpImageMapTool *im_tool,
+ GObject **config);
static void gimp_threshold_tool_map (GimpImageMapTool *im_tool);
static void gimp_threshold_tool_dialog (GimpImageMapTool *im_tool);
-static void gimp_threshold_tool_reset (GimpImageMapTool *im_tool);
+
+static void gimp_threshold_tool_config_notify (GObject *object,
+ GParamSpec *pspec,
+ GimpThresholdTool *t_tool);
static void gimp_threshold_tool_histogram_range (GimpHistogramView *view,
gint start,
@@ -107,7 +111,6 @@
im_tool_class->get_operation = gimp_threshold_tool_get_operation;
im_tool_class->map = gimp_threshold_tool_map;
im_tool_class->dialog = gimp_threshold_tool_dialog;
- im_tool_class->reset = gimp_threshold_tool_reset;
}
static void
@@ -127,12 +130,6 @@
{
GimpThresholdTool *t_tool = GIMP_THRESHOLD_TOOL (object);
- if (t_tool->config)
- {
- g_object_unref (t_tool->config);
- t_tool->config = NULL;
- }
-
g_slice_free (Threshold, t_tool->threshold);
if (t_tool->hist)
@@ -191,7 +188,8 @@
}
static GeglNode *
-gimp_threshold_tool_get_operation (GimpImageMapTool *image_map_tool)
+gimp_threshold_tool_get_operation (GimpImageMapTool *image_map_tool,
+ GObject **config)
{
GimpThresholdTool *t_tool = GIMP_THRESHOLD_TOOL (image_map_tool);
GeglNode *node;
@@ -202,6 +200,12 @@
t_tool->config = g_object_new (GIMP_TYPE_THRESHOLD_CONFIG, NULL);
+ *config = G_OBJECT (t_tool->config);
+
+ g_signal_connect_object (t_tool->config, "notify",
+ G_CALLBACK (gimp_threshold_tool_config_notify),
+ G_OBJECT (t_tool), 0);
+
gegl_node_set (node,
"config", t_tool->config,
NULL);
@@ -274,15 +278,18 @@
}
static void
-gimp_threshold_tool_reset (GimpImageMapTool *image_map_tool)
-{
- GimpThresholdTool *t_tool = GIMP_THRESHOLD_TOOL (image_map_tool);
-
- gimp_config_reset (GIMP_CONFIG (t_tool->config));
+gimp_threshold_tool_config_notify (GObject *object,
+ GParamSpec *pspec,
+ GimpThresholdTool *t_tool)
+{
+ GimpThresholdConfig *config = GIMP_THRESHOLD_CONFIG (object);
+
+ if (t_tool->histogram_box)
+ gimp_histogram_view_set_range (t_tool->histogram_box->view,
+ config->low * 255.999,
+ config->high * 255.999);
- gimp_histogram_view_set_range (t_tool->histogram_box->view,
- t_tool->config->low * 255.999,
- t_tool->config->high * 255.999);
+ gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (t_tool));
}
static void
@@ -301,8 +308,6 @@
"low", low,
"high", high,
NULL);
-
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (t_tool));
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]