[gimp] app: move stuff from GimpOperationTool to GimpImageMapTool
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: move stuff from GimpOperationTool to GimpImageMapTool
- Date: Fri, 22 Jan 2016 20:29:35 +0000 (UTC)
commit 8c09210d7d7ee21d88f3c529394e91fd827d6322
Author: Michael Natterer <mitch gimp org>
Date: Fri Jan 22 21:22:36 2016 +0100
app: move stuff from GimpOperationTool to GimpImageMapTool
Add new string members to GimpImageMapTool and use them instead of the
resp. fields of GimpToolInfo. Change ::get_operation() to return the
operation name and a lot of strings for the UI, and create both the
GeglNode and the config object in GimpOperationTool. Lots of various
cleanups in GimpImageMapTool subclasses. This is an intermediate state
on the way of making the whole filter applying mechanism more generic
and less depending on subclasses.
app/actions/gimpgeglprocedure.c | 1 +
app/tools/gimpbrightnesscontrasttool.c | 49 +++--
app/tools/gimpbrightnesscontrasttool.h | 12 +-
app/tools/gimpcolorbalancetool.c | 49 +++---
app/tools/gimpcolorbalancetool.h | 4 +-
app/tools/gimpcolorizetool.c | 44 ++--
app/tools/gimpcurvestool.c | 133 +++++++------
app/tools/gimpcurvestool.h | 18 +-
app/tools/gimpgegltool.c | 43 ++++-
app/tools/gimphuesaturationtool.c | 110 ++++++-----
app/tools/gimphuesaturationtool.h | 8 +-
app/tools/gimpimagemaptool.c | 343 ++++++++++++++++++++------------
app/tools/gimpimagemaptool.h | 16 +-
app/tools/gimplevelstool.c | 165 ++++++++-------
app/tools/gimplevelstool.h | 2 -
app/tools/gimpoperationtool.c | 103 ++++------
app/tools/gimpoperationtool.h | 2 +
app/tools/gimpthresholdtool.c | 120 +++++++-----
app/tools/gimpthresholdtool.h | 8 +-
19 files changed, 692 insertions(+), 538 deletions(-)
---
diff --git a/app/actions/gimpgeglprocedure.c b/app/actions/gimpgeglprocedure.c
index 51fcf88..625acdb 100644
--- a/app/actions/gimpgeglprocedure.c
+++ b/app/actions/gimpgeglprocedure.c
@@ -323,6 +323,7 @@ gimp_gegl_procedure_execute_async (GimpProcedure *procedure,
procedure->original_name,
gimp_procedure_get_label (procedure),
gimp_procedure_get_label (procedure),
+ gimp_procedure_get_label (procedure),
gimp_viewable_get_icon_name (GIMP_VIEWABLE (procedure)),
gimp_procedure_get_help_id (procedure));
diff --git a/app/tools/gimpbrightnesscontrasttool.c b/app/tools/gimpbrightnesscontrasttool.c
index 06f94e8..9792744 100644
--- a/app/tools/gimpbrightnesscontrasttool.c
+++ b/app/tools/gimpbrightnesscontrasttool.c
@@ -71,10 +71,13 @@ static void gimp_brightness_contrast_tool_motion (GimpTool
GdkModifierType state,
GimpDisplay *display);
-static GeglNode *
+static gchar *
gimp_brightness_contrast_tool_get_operation (GimpImageMapTool *image_map_tool,
- GObject **config,
- gchar **undo_desc);
+ gchar **title,
+ gchar **description,
+ gchar **undo_desc,
+ gchar **icon_name,
+ gchar **help_id);
static void gimp_brightness_contrast_tool_dialog (GimpImageMapTool *image_map_tool);
static void brightness_contrast_to_levels_callback (GtkWidget *widget,
@@ -114,7 +117,6 @@ gimp_brightness_contrast_tool_class_init (GimpBrightnessContrastToolClass *klass
tool_class->button_release = gimp_brightness_contrast_tool_button_release;
tool_class->motion = gimp_brightness_contrast_tool_motion;
- im_tool_class->dialog_desc = _("Adjust Brightness and Contrast");
im_tool_class->settings_name = "brightness-contrast";
im_tool_class->import_dialog_title = _("Import Brightness-Contrast settings");
im_tool_class->export_dialog_title = _("Export Brightness-Contrast settings");
@@ -160,21 +162,17 @@ gimp_brightness_contrast_tool_initialize (GimpTool *tool,
return TRUE;
}
-static GeglNode *
+static gchar *
gimp_brightness_contrast_tool_get_operation (GimpImageMapTool *im_tool,
- GObject **config,
- gchar **undo_desc)
+ gchar **title,
+ gchar **description,
+ gchar **undo_desc,
+ gchar **icon_name,
+ gchar **help_id)
{
- GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (im_tool);
+ *description = g_strdup (_("Adjust Brightness and Contrast"));
- bc_tool->config = g_object_new (GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG, NULL);
-
- *config = G_OBJECT (bc_tool->config);
-
- return gegl_node_new_child (NULL,
- "operation", "gimp:brightness-contrast",
- "config", bc_tool->config,
- NULL);
+ return g_strdup ("gimp:brightness-contrast");
}
static void
@@ -186,11 +184,18 @@ gimp_brightness_contrast_tool_button_press (GimpTool *tool,
GimpDisplay *display)
{
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (tool);
+ gdouble brightness;
+ gdouble contrast;
+
+ g_object_get (GIMP_IMAGE_MAP_TOOL (tool)->config,
+ "brightness", &brightness,
+ "contrast", &contrast,
+ NULL);
- bc_tool->x = coords->x - bc_tool->config->contrast * 127.0;
- bc_tool->y = coords->y + bc_tool->config->brightness * 127.0;
- bc_tool->dx = bc_tool->config->contrast * 127.0;
- bc_tool->dy = - bc_tool->config->brightness * 127.0;
+ bc_tool->x = coords->x - contrast * 127.0;
+ bc_tool->y = coords->y + brightness * 127.0;
+ bc_tool->dx = contrast * 127.0;
+ bc_tool->dy = - brightness * 127.0;
gimp_tool_control_activate (tool->control);
tool->display = display;
@@ -212,7 +217,7 @@ gimp_brightness_contrast_tool_button_release (GimpTool *tool,
return;
if (release_type == GIMP_BUTTON_RELEASE_CANCEL)
- gimp_config_reset (GIMP_CONFIG (bc_tool->config));
+ gimp_config_reset (GIMP_CONFIG (GIMP_IMAGE_MAP_TOOL (tool)->config));
}
static void
@@ -227,7 +232,7 @@ gimp_brightness_contrast_tool_motion (GimpTool *tool,
bc_tool->dx = (coords->x - bc_tool->x);
bc_tool->dy = - (coords->y - bc_tool->y);
- g_object_set (bc_tool->config,
+ g_object_set (GIMP_IMAGE_MAP_TOOL (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);
diff --git a/app/tools/gimpbrightnesscontrasttool.h b/app/tools/gimpbrightnesscontrasttool.h
index 9a02737..d7bfd05 100644
--- a/app/tools/gimpbrightnesscontrasttool.h
+++ b/app/tools/gimpbrightnesscontrasttool.h
@@ -35,16 +35,14 @@ typedef struct _GimpBrightnessContrastToolClass GimpBrightnessContrastToolClass;
struct _GimpBrightnessContrastTool
{
- GimpImageMapTool parent_instance;
+ GimpImageMapTool parent_instance;
- GimpBrightnessContrastConfig *config;
-
- gdouble x, y;
- gdouble dx, dy;
+ gdouble x, y;
+ gdouble dx, dy;
/* dialog */
- GtkWidget *brightness_scale;
- GtkWidget *contrast_scale;
+ GtkWidget *brightness_scale;
+ GtkWidget *contrast_scale;
};
struct _GimpBrightnessContrastToolClass
diff --git a/app/tools/gimpcolorbalancetool.c b/app/tools/gimpcolorbalancetool.c
index 9544bf9..7de7d8d 100644
--- a/app/tools/gimpcolorbalancetool.c
+++ b/app/tools/gimpcolorbalancetool.c
@@ -51,14 +51,17 @@ static gboolean gimp_color_balance_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error);
-static GeglNode * gimp_color_balance_tool_get_operation (GimpImageMapTool *im_tool,
- GObject **config,
- gchar **undo_desc);
+static gchar * gimp_color_balance_tool_get_operation (GimpImageMapTool *im_tool,
+ gchar **title,
+ gchar **description,
+ gchar **undo_desc,
+ gchar **icon_name,
+ gchar **help_id);
static void gimp_color_balance_tool_dialog (GimpImageMapTool *im_tool);
static void gimp_color_balance_tool_reset (GimpImageMapTool *im_tool);
-static void color_balance_range_reset_callback (GtkWidget *widget,
- GimpColorBalanceTool *cb_tool);
+static void color_balance_range_reset_callback (GtkWidget *widget,
+ GimpImageMapTool *im_tool);
G_DEFINE_TYPE (GimpColorBalanceTool, gimp_color_balance_tool,
@@ -91,7 +94,6 @@ gimp_color_balance_tool_class_init (GimpColorBalanceToolClass *klass)
tool_class->initialize = gimp_color_balance_tool_initialize;
- im_tool_class->dialog_desc = _("Adjust Color Balance");
im_tool_class->settings_name = "color-balance";
im_tool_class->import_dialog_title = _("Import Color Balance Settings");
im_tool_class->export_dialog_title = _("Export Color Balance Settings");
@@ -127,21 +129,17 @@ gimp_color_balance_tool_initialize (GimpTool *tool,
return GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
}
-static GeglNode *
+static gchar *
gimp_color_balance_tool_get_operation (GimpImageMapTool *im_tool,
- GObject **config,
- gchar **undo_desc)
+ gchar **title,
+ gchar **description,
+ gchar **undo_desc,
+ gchar **icon_name,
+ gchar **help_id)
{
- GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (im_tool);
+ *description = g_strdup (_("Adjust Color Balance"));
- cb_tool->config = g_object_new (GIMP_TYPE_COLOR_BALANCE_CONFIG, NULL);
-
- *config = G_OBJECT (cb_tool->config);
-
- return gegl_node_new_child (NULL,
- "operation", "gimp:color-balance",
- "config", cb_tool->config,
- NULL);
+ return g_strdup ("gimp:color-balance");
}
@@ -248,19 +246,22 @@ gimp_color_balance_tool_dialog (GimpImageMapTool *image_map_tool)
static void
gimp_color_balance_tool_reset (GimpImageMapTool *im_tool)
{
- GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (im_tool);
- GimpTransferMode range = cb_tool->config->range;
+ GimpTransferMode range;
+
+ g_object_get (im_tool->config,
+ "range", &range,
+ NULL);
GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->reset (im_tool);
- g_object_set (cb_tool->config,
+ g_object_set (im_tool->config,
"range", range,
NULL);
}
static void
-color_balance_range_reset_callback (GtkWidget *widget,
- GimpColorBalanceTool *cb_tool)
+color_balance_range_reset_callback (GtkWidget *widget,
+ GimpImageMapTool *im_tool)
{
- gimp_color_balance_config_reset_range (cb_tool->config);
+ gimp_color_balance_config_reset_range (GIMP_COLOR_BALANCE_CONFIG (im_tool->config));
}
diff --git a/app/tools/gimpcolorbalancetool.h b/app/tools/gimpcolorbalancetool.h
index 3032b83..2a1bdbb 100644
--- a/app/tools/gimpcolorbalancetool.h
+++ b/app/tools/gimpcolorbalancetool.h
@@ -36,9 +36,7 @@ typedef struct _GimpColorBalanceToolClass GimpColorBalanceToolClass;
struct _GimpColorBalanceTool
{
- GimpImageMapTool parent_instance;
-
- GimpColorBalanceConfig *config;
+ GimpImageMapTool parent_instance;
};
struct _GimpColorBalanceToolClass
diff --git a/app/tools/gimpcolorizetool.c b/app/tools/gimpcolorizetool.c
index 3c8edc3..2ccb298 100644
--- a/app/tools/gimpcolorizetool.c
+++ b/app/tools/gimpcolorizetool.c
@@ -27,8 +27,6 @@
#include "tools-types.h"
-#include "operations/gimpcolorizeconfig.h"
-
#include "core/gimpdrawable.h"
#include "core/gimperror.h"
#include "core/gimpimage.h"
@@ -52,9 +50,12 @@ static gboolean gimp_colorize_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error);
-static GeglNode * gimp_colorize_tool_get_operation (GimpImageMapTool *im_tool,
- GObject **config,
- gchar **undo_desc);
+static gchar * gimp_colorize_tool_get_operation (GimpImageMapTool *im_tool,
+ gchar **title,
+ gchar **description,
+ gchar **undo_desc,
+ gchar **icon_name,
+ gchar **help_id);
static void gimp_colorize_tool_dialog (GimpImageMapTool *im_tool);
static void gimp_colorize_tool_color_picked (GimpImageMapTool *im_tool,
gpointer identifier,
@@ -94,7 +95,6 @@ gimp_colorize_tool_class_init (GimpColorizeToolClass *klass)
tool_class->initialize = gimp_colorize_tool_initialize;
- im_tool_class->dialog_desc = _("Colorize the Image");
im_tool_class->settings_name = "colorize";
im_tool_class->import_dialog_title = _("Import Colorize Settings");
im_tool_class->export_dialog_title = _("Export Colorize Settings");
@@ -130,17 +130,17 @@ gimp_colorize_tool_initialize (GimpTool *tool,
return GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
}
-static GeglNode *
+static gchar *
gimp_colorize_tool_get_operation (GimpImageMapTool *im_tool,
- GObject **config,
- gchar **undo_desc)
+ gchar **title,
+ gchar **description,
+ gchar **undo_desc,
+ gchar **icon_name,
+ gchar **help_id)
{
- *config = g_object_new (GIMP_TYPE_COLORIZE_CONFIG, NULL);
+ *description = g_strdup (_("Colorize the Image"));
- return gegl_node_new_child (NULL,
- "operation", "gimp:colorize",
- "config", *config,
- NULL);
+ return g_strdup ("gimp:colorize");
}
@@ -149,9 +149,9 @@ gimp_colorize_tool_get_operation (GimpImageMapTool *im_tool,
/***************************/
static void
-gimp_colorize_tool_dialog (GimpImageMapTool *image_map_tool)
+gimp_colorize_tool_dialog (GimpImageMapTool *im_tool)
{
- GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (image_map_tool);
+ GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (im_tool);
GtkWidget *main_vbox;
GtkWidget *frame;
GtkWidget *vbox;
@@ -159,7 +159,7 @@ gimp_colorize_tool_dialog (GimpImageMapTool *image_map_tool)
GtkWidget *hbox;
GtkWidget *button;
- main_vbox = gimp_image_map_tool_dialog_get_vbox (image_map_tool);
+ main_vbox = gimp_image_map_tool_dialog_get_vbox (im_tool);
frame = gimp_frame_new (_("Select Color"));
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
@@ -170,21 +170,21 @@ gimp_colorize_tool_dialog (GimpImageMapTool *image_map_tool)
gtk_widget_show (vbox);
/* Create the hue scale widget */
- scale = gimp_prop_spin_scale_new (image_map_tool->config, "hue",
+ scale = gimp_prop_spin_scale_new (im_tool->config, "hue",
_("_Hue"), 1.0 / 360.0, 15.0 / 360.0, 0);
gimp_prop_widget_set_factor (scale, 360.0, 0.0, 0.0, 1);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
gtk_widget_show (scale);
/* Create the saturation scale widget */
- scale = gimp_prop_spin_scale_new (image_map_tool->config, "saturation",
+ scale = gimp_prop_spin_scale_new (im_tool->config, "saturation",
_("_Saturation"), 0.01, 0.1, 0);
gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
gtk_widget_show (scale);
/* Create the lightness scale widget */
- scale = gimp_prop_spin_scale_new (image_map_tool->config, "lightness",
+ scale = gimp_prop_spin_scale_new (im_tool->config, "lightness",
_("_Lightness"), 0.01, 0.1, 0);
gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
@@ -195,7 +195,7 @@ gimp_colorize_tool_dialog (GimpImageMapTool *image_map_tool)
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
- button = gimp_prop_color_button_new (image_map_tool->config, "color",
+ button = gimp_prop_color_button_new (im_tool->config, "color",
_("Colorize Color"),
128, 24,
GIMP_COLOR_AREA_FLAT);
@@ -205,7 +205,7 @@ gimp_colorize_tool_dialog (GimpImageMapTool *image_map_tool)
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
gtk_widget_show (button);
- button = gimp_image_map_tool_add_color_picker (image_map_tool,
+ button = gimp_image_map_tool_add_color_picker (im_tool,
"colorize",
GIMP_STOCK_COLOR_PICKER_GRAY,
_("Pick color from image"));
diff --git a/app/tools/gimpcurvestool.c b/app/tools/gimpcurvestool.c
index 7ebca21..32782f0 100644
--- a/app/tools/gimpcurvestool.c
+++ b/app/tools/gimpcurvestool.c
@@ -89,15 +89,19 @@ static void gimp_curves_tool_color_picked (GimpColorTool *color_t
const Babl *sample_format,
gpointer pixel,
const GimpRGB *color);
-static GeglNode * gimp_curves_tool_get_operation (GimpImageMapTool *image_map_tool,
- GObject **config,
- gchar **undo_desc);
-static void gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool);
-static void gimp_curves_tool_reset (GimpImageMapTool *image_map_tool);
-static gboolean gimp_curves_tool_settings_import(GimpImageMapTool *image_map_tool,
+
+static gchar * gimp_curves_tool_get_operation (GimpImageMapTool *im_tool,
+ gchar **title,
+ gchar **description,
+ gchar **undo_desc,
+ gchar **icon_name,
+ gchar **help_id);
+static void gimp_curves_tool_dialog (GimpImageMapTool *im_tool);
+static void gimp_curves_tool_reset (GimpImageMapTool *im_tool);
+static gboolean gimp_curves_tool_settings_import(GimpImageMapTool *im_tool,
GInputStream *input,
GError **error);
-static gboolean gimp_curves_tool_settings_export(GimpImageMapTool *image_map_tool,
+static gboolean gimp_curves_tool_settings_export(GimpImageMapTool *im_tool,
GOutputStream *output,
GError **error);
@@ -168,7 +172,6 @@ gimp_curves_tool_class_init (GimpCurvesToolClass *klass)
color_tool_class->picked = gimp_curves_tool_color_picked;
- im_tool_class->dialog_desc = _("Adjust Color Curves");
im_tool_class->settings_name = "curves";
im_tool_class->import_dialog_title = _("Import Curves");
im_tool_class->export_dialog_title = _("Export Curves");
@@ -194,6 +197,10 @@ gimp_curves_tool_constructed (GObject *object)
{
G_OBJECT_CLASS (parent_class)->constructed (object);
+ g_signal_connect_object (GIMP_IMAGE_MAP_TOOL (object)->config, "notify",
+ G_CALLBACK (gimp_curves_tool_config_notify),
+ object, 0);
+
/* always pick colors */
gimp_color_tool_enable (GIMP_COLOR_TOOL (object),
GIMP_COLOR_TOOL_GET_OPTIONS (object));
@@ -246,8 +253,9 @@ gimp_curves_tool_button_release (GimpTool *tool,
GimpButtonReleaseType release_type,
GimpDisplay *display)
{
- GimpCurvesTool *c_tool = GIMP_CURVES_TOOL (tool);
- GimpCurvesConfig *config = c_tool->config;
+ GimpCurvesTool *c_tool = GIMP_CURVES_TOOL (tool);
+ GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (tool);
+ GimpCurvesConfig *config = GIMP_CURVES_CONFIG (im_tool->config);
if (state & gimp_get_extend_selection_mask ())
{
@@ -363,8 +371,10 @@ gimp_curves_tool_color_picked (GimpColorTool *color_tool,
gpointer pixel,
const GimpRGB *color)
{
- GimpCurvesTool *tool = GIMP_CURVES_TOOL (color_tool);
- GimpDrawable *drawable;
+ GimpCurvesTool *tool = GIMP_CURVES_TOOL (color_tool);
+ GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (color_tool);
+ GimpCurvesConfig *config = GIMP_CURVES_CONFIG (im_tool->config);
+ GimpDrawable *drawable;
drawable = GIMP_IMAGE_MAP_TOOL (tool)->drawable;
@@ -381,28 +391,20 @@ gimp_curves_tool_color_picked (GimpColorTool *color_tool,
color->b);
gimp_curve_view_set_xpos (GIMP_CURVE_VIEW (tool->graph),
- tool->picked_color[tool->config->channel]);
+ tool->picked_color[config->channel]);
}
-static GeglNode *
-gimp_curves_tool_get_operation (GimpImageMapTool *image_map_tool,
- GObject **config,
- gchar **undo_desc)
+static gchar *
+gimp_curves_tool_get_operation (GimpImageMapTool *im_tool,
+ gchar **title,
+ gchar **description,
+ gchar **undo_desc,
+ gchar **icon_name,
+ gchar **help_id)
{
- GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool);
-
- tool->config = g_object_new (GIMP_TYPE_CURVES_CONFIG, NULL);
+ *description = g_strdup (_("Adjust Color Curves"));
- g_signal_connect_object (tool->config, "notify",
- G_CALLBACK (gimp_curves_tool_config_notify),
- tool, 0);
-
- *config = G_OBJECT (tool->config);
-
- return gegl_node_new_child (NULL,
- "operation", "gimp:curves",
- "config", tool->config,
- NULL);
+ return g_strdup ("gimp:curves");
}
@@ -411,11 +413,11 @@ gimp_curves_tool_get_operation (GimpImageMapTool *image_map_tool,
/*******************/
static void
-gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool)
+gimp_curves_tool_dialog (GimpImageMapTool *im_tool)
{
- GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool);
- GimpToolOptions *tool_options = GIMP_TOOL_GET_OPTIONS (image_map_tool);
- GimpCurvesConfig *config = tool->config;
+ GimpCurvesTool *tool = GIMP_CURVES_TOOL (im_tool);
+ GimpToolOptions *tool_options = GIMP_TOOL_GET_OPTIONS (im_tool);
+ GimpCurvesConfig *config = GIMP_CURVES_CONFIG (im_tool->config);
GtkListStore *store;
GtkSizeGroup *label_group;
GtkWidget *main_vbox;
@@ -429,12 +431,12 @@ gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool)
GtkWidget *bar;
GtkWidget *combo;
- g_signal_connect (image_map_tool->settings_box, "file-dialog-setup",
+ g_signal_connect (im_tool->settings_box, "file-dialog-setup",
G_CALLBACK (gimp_curves_tool_export_setup),
- image_map_tool);
+ im_tool);
- main_vbox = gimp_image_map_tool_dialog_get_vbox (image_map_tool);
- label_group = gimp_image_map_tool_dialog_get_label_group (image_map_tool);
+ main_vbox = gimp_image_map_tool_dialog_get_vbox (im_tool);
+ label_group = gimp_image_map_tool_dialog_get_label_group (im_tool);
/* The combo box for selecting channels */
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
@@ -577,13 +579,13 @@ gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool)
}
static void
-gimp_curves_tool_reset (GimpImageMapTool *image_map_tool)
+gimp_curves_tool_reset (GimpImageMapTool *im_tool)
{
- GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool);
+ GimpCurvesConfig *config = GIMP_CURVES_CONFIG (im_tool->config);
GimpCurvesConfig *default_config;
GimpHistogramChannel channel;
- default_config = GIMP_CURVES_CONFIG (image_map_tool->default_config);
+ default_config = GIMP_CURVES_CONFIG (im_tool->default_config);
for (channel = GIMP_HISTOGRAM_VALUE;
channel <= GIMP_HISTOGRAM_ALPHA;
@@ -591,35 +593,35 @@ gimp_curves_tool_reset (GimpImageMapTool *image_map_tool)
{
if (default_config)
{
- GimpCurveType curve_type = tool->config->curve[channel]->curve_type;
+ GimpCurveType curve_type = config->curve[channel]->curve_type;
- g_object_freeze_notify (G_OBJECT (tool->config->curve[channel]));
+ g_object_freeze_notify (G_OBJECT (config->curve[channel]));
gimp_config_copy (GIMP_CONFIG (default_config->curve[channel]),
- GIMP_CONFIG (tool->config->curve[channel]),
+ GIMP_CONFIG (config->curve[channel]),
0);
- g_object_set (tool->config->curve[channel],
+ g_object_set (config->curve[channel],
"curve-type", curve_type,
NULL);
- g_object_thaw_notify (G_OBJECT (tool->config->curve[channel]));
+ g_object_thaw_notify (G_OBJECT (config->curve[channel]));
}
else
{
- gimp_curve_reset (tool->config->curve[channel], FALSE);
+ gimp_curve_reset (config->curve[channel], FALSE);
}
}
}
static gboolean
-gimp_curves_tool_settings_import (GimpImageMapTool *image_map_tool,
+gimp_curves_tool_settings_import (GimpImageMapTool *im_tool,
GInputStream *input,
GError **error)
{
- GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool);
- gchar header[64];
- gsize bytes_read;
+ GimpCurvesConfig *config = GIMP_CURVES_CONFIG (im_tool->config);
+ gchar header[64];
+ gsize bytes_read;
if (! g_input_stream_read_all (input, header, sizeof (header),
&bytes_read, NULL, error) ||
@@ -632,24 +634,25 @@ gimp_curves_tool_settings_import (GimpImageMapTool *image_map_tool,
g_seekable_seek (G_SEEKABLE (input), 0, G_SEEK_SET, NULL, NULL);
if (g_str_has_prefix (header, "# GIMP Curves File\n"))
- return gimp_curves_config_load_cruft (tool->config, input, error);
+ return gimp_curves_config_load_cruft (config, input, error);
- return GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->settings_import (image_map_tool,
+ return GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->settings_import (im_tool,
input,
error);
}
static gboolean
-gimp_curves_tool_settings_export (GimpImageMapTool *image_map_tool,
+gimp_curves_tool_settings_export (GimpImageMapTool *im_tool,
GOutputStream *output,
GError **error)
{
- GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool);
+ GimpCurvesTool *tool = GIMP_CURVES_TOOL (im_tool);
+ GimpCurvesConfig *config = GIMP_CURVES_CONFIG (im_tool->config);
if (tool->export_old_format)
- return gimp_curves_config_save_cruft (tool->config, output, error);
+ return gimp_curves_config_save_cruft (config, output, error);
- return GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->settings_export (image_map_tool,
+ return GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->settings_export (im_tool,
output,
error);
}
@@ -679,8 +682,9 @@ gimp_curves_tool_export_setup (GimpSettingsBox *settings_box,
static void
gimp_curves_tool_update_channel (GimpCurvesTool *tool)
{
- GimpCurvesConfig *config = GIMP_CURVES_TOOL (tool)->config;
- GimpCurve *curve = config->curve[config->channel];
+ GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (tool);
+ GimpCurvesConfig *config = GIMP_CURVES_CONFIG (im_tool->config);
+ GimpCurve *curve = config->curve[config->channel];
GimpHistogramChannel channel;
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (tool->channel_menu),
@@ -773,7 +777,8 @@ static void
curves_channel_callback (GtkWidget *widget,
GimpCurvesTool *tool)
{
- GimpCurvesConfig *config = tool->config;
+ GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (tool);
+ GimpCurvesConfig *config = GIMP_CURVES_CONFIG (im_tool->config);
gint value;
if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value) &&
@@ -789,7 +794,10 @@ static void
curves_channel_reset_callback (GtkWidget *widget,
GimpCurvesTool *tool)
{
- gimp_curve_reset (tool->config->curve[tool->config->channel], FALSE);
+ GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (tool);
+ GimpCurvesConfig *config = GIMP_CURVES_CONFIG (im_tool->config);
+
+ gimp_curve_reset (config->curve[config->channel], FALSE);
}
static gboolean
@@ -827,7 +835,8 @@ curves_curve_type_callback (GtkWidget *widget,
if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value))
{
- GimpCurvesConfig *config = tool->config;
+ GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (tool);
+ GimpCurvesConfig *config = GIMP_CURVES_CONFIG (im_tool->config);
GimpCurveType curve_type = value;
if (config->curve[config->channel]->curve_type != curve_type)
diff --git a/app/tools/gimpcurvestool.h b/app/tools/gimpcurvestool.h
index fea4f32..f1c9762 100644
--- a/app/tools/gimpcurvestool.h
+++ b/app/tools/gimpcurvestool.h
@@ -34,21 +34,19 @@ typedef struct _GimpCurvesToolClass GimpCurvesToolClass;
struct _GimpCurvesTool
{
- GimpImageMapTool parent_instance;
-
- GimpCurvesConfig *config;
+ GimpImageMapTool parent_instance;
/* dialog */
- gdouble picked_color[5];
+ gdouble picked_color[5];
- GtkWidget *channel_menu;
- GtkWidget *xrange;
- GtkWidget *yrange;
- GtkWidget *graph;
- GtkWidget *curve_type;
+ GtkWidget *channel_menu;
+ GtkWidget *xrange;
+ GtkWidget *yrange;
+ GtkWidget *graph;
+ GtkWidget *curve_type;
/* export dialog */
- gboolean export_old_format;
+ gboolean export_old_format;
};
struct _GimpCurvesToolClass
diff --git a/app/tools/gimpgegltool.c b/app/tools/gimpgegltool.c
index b2f21c4..9d74e8c 100644
--- a/app/tools/gimpgegltool.c
+++ b/app/tools/gimpgegltool.c
@@ -49,10 +49,16 @@ enum
/* local function prototypes */
-static void gimp_gegl_tool_dialog (GimpImageMapTool *im_tool);
+static gchar * gimp_gegl_tool_get_operation (GimpImageMapTool *im_tool,
+ gchar **title,
+ gchar **description,
+ gchar **undo_desc,
+ gchar **icon_name,
+ gchar **help_id);
+static void gimp_gegl_tool_dialog (GimpImageMapTool *im_tool);
-static void gimp_gegl_tool_operation_changed (GtkWidget *widget,
- GimpGeglTool *tool);
+static void gimp_gegl_tool_operation_changed (GtkWidget *widget,
+ GimpGeglTool *tool);
G_DEFINE_TYPE (GimpGeglTool, gimp_gegl_tool, GIMP_TYPE_OPERATION_TOOL)
@@ -82,9 +88,8 @@ gimp_gegl_tool_class_init (GimpGeglToolClass *klass)
{
GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
- im_tool_class->dialog_desc = _("GEGL Operation");
-
- im_tool_class->dialog = gimp_gegl_tool_dialog;
+ im_tool_class->get_operation = gimp_gegl_tool_get_operation;
+ im_tool_class->dialog = gimp_gegl_tool_dialog;
}
static void
@@ -324,6 +329,31 @@ gimp_get_geglopclasses (void)
/* Gegl dialog */
/*****************/
+static gchar *
+gimp_gegl_tool_get_operation (GimpImageMapTool *im_tool,
+ gchar **title,
+ gchar **description,
+ gchar **undo_desc,
+ gchar **icon_name,
+ gchar **help_id)
+{
+ gchar *operation;
+
+ operation = GIMP_IMAGE_MAP_TOOL_GET_CLASS (im_tool)->get_operation (im_tool,
+ title,
+ description,
+ undo_desc,
+ icon_name,
+ help_id);
+
+ if (*description)
+ g_free (*description);
+
+ *description = g_strdup (_("GEGL Operation"));
+
+ return operation;
+}
+
static void
gimp_gegl_tool_dialog (GimpImageMapTool *image_map_tool)
{
@@ -463,6 +493,7 @@ gimp_gegl_tool_operation_changed (GtkWidget *widget,
gimp_operation_tool_set_operation (GIMP_OPERATION_TOOL (tool),
operation,
_("GEGL Operation"),
+ _("GEGL Operation"),
NULL,
GIMP_STOCK_GEGL,
GIMP_HELP_TOOL_GEGL);
diff --git a/app/tools/gimphuesaturationtool.c b/app/tools/gimphuesaturationtool.c
index e3d462d..eb60fa8 100644
--- a/app/tools/gimphuesaturationtool.c
+++ b/app/tools/gimphuesaturationtool.c
@@ -52,13 +52,18 @@
/* local function prototypes */
+static void gimp_hue_saturation_tool_constructed (GObject *object);
+
static gboolean gimp_hue_saturation_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error);
-static GeglNode * gimp_hue_saturation_tool_get_operation (GimpImageMapTool *im_tool,
- GObject **config,
- gchar **undo_desc);
+static gchar * gimp_hue_saturation_tool_get_operation (GimpImageMapTool *im_tool,
+ gchar **title,
+ gchar **description,
+ gchar **undo_desc,
+ gchar **icon_name,
+ gchar **help_id);
static void gimp_hue_saturation_tool_dialog (GimpImageMapTool *im_tool);
static void gimp_hue_saturation_tool_reset (GimpImageMapTool *im_tool);
@@ -69,9 +74,9 @@ static void hue_saturation_config_notify (GObject
static void hue_saturation_update_color_areas (GimpHueSaturationTool *hs_tool);
static void hue_saturation_range_callback (GtkWidget *widget,
- GimpHueSaturationTool *hs_tool);
+ GimpImageMapTool *im_tool);
static void hue_saturation_range_reset_callback (GtkWidget *widget,
- GimpHueSaturationTool *hs_tool);
+ GimpImageMapTool *hs_tool);
G_DEFINE_TYPE (GimpHueSaturationTool, gimp_hue_saturation_tool,
@@ -99,12 +104,14 @@ gimp_hue_saturation_tool_register (GimpToolRegisterCallback callback,
static void
gimp_hue_saturation_tool_class_init (GimpHueSaturationToolClass *klass)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
+ object_class->constructed = gimp_hue_saturation_tool_constructed;
+
tool_class->initialize = gimp_hue_saturation_tool_initialize;
- im_tool_class->dialog_desc = _("Adjust Hue / Lightness / Saturation");
im_tool_class->settings_name = "hue-saturation";
im_tool_class->import_dialog_title = _("Import Hue-Saturation Settings");
im_tool_class->export_dialog_title = _("Export Hue-Saturation Settings");
@@ -119,6 +126,16 @@ gimp_hue_saturation_tool_init (GimpHueSaturationTool *hs_tool)
{
}
+static void
+gimp_hue_saturation_tool_constructed (GObject *object)
+{
+ G_OBJECT_CLASS (parent_class)->constructed (object);
+
+ g_signal_connect_object (GIMP_IMAGE_MAP_TOOL (object)->config, "notify",
+ G_CALLBACK (hue_saturation_config_notify),
+ object, 0);
+}
+
static gboolean
gimp_hue_saturation_tool_initialize (GimpTool *tool,
GimpDisplay *display,
@@ -140,25 +157,17 @@ gimp_hue_saturation_tool_initialize (GimpTool *tool,
return GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
}
-static GeglNode *
+static gchar *
gimp_hue_saturation_tool_get_operation (GimpImageMapTool *im_tool,
- GObject **config,
- gchar **undo_desc)
+ gchar **title,
+ gchar **description,
+ gchar **undo_desc,
+ gchar **icon_name,
+ gchar **help_id)
{
- GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (im_tool);
-
- hs_tool->config = g_object_new (GIMP_TYPE_HUE_SATURATION_CONFIG, NULL);
-
- g_signal_connect_object (hs_tool->config, "notify",
- G_CALLBACK (hue_saturation_config_notify),
- G_OBJECT (hs_tool), 0);
+ *description = g_strdup (_("Adjust Hue / Lightness / Saturation"));
- *config = G_OBJECT (hs_tool->config);
-
- return gegl_node_new_child (NULL,
- "operation", "gimp:hue-saturation",
- "config", hs_tool->config,
- NULL);
+ return g_strdup ("gimp:hue-saturation");
}
@@ -167,10 +176,10 @@ gimp_hue_saturation_tool_get_operation (GimpImageMapTool *im_tool,
/***************************/
static void
-gimp_hue_saturation_tool_dialog (GimpImageMapTool *image_map_tool)
+gimp_hue_saturation_tool_dialog (GimpImageMapTool *im_tool)
{
- GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (image_map_tool);
- GimpHueSaturationConfig *config = hs_tool->config;
+ GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (im_tool);
+ GimpHueSaturationConfig *config = GIMP_HUE_SATURATION_CONFIG (im_tool->config);
GtkWidget *main_vbox;
GtkWidget *frame;
GtkWidget *vbox;
@@ -202,7 +211,7 @@ gimp_hue_saturation_tool_dialog (GimpImageMapTool *image_map_tool)
{ N_("_M"), N_("Magenta"), 3, 2, 4, 2 }
};
- main_vbox = gimp_image_map_tool_dialog_get_vbox (image_map_tool);
+ main_vbox = gimp_image_map_tool_dialog_get_vbox (im_tool);
frame = gimp_frame_new (_("Select Primary Color to Adjust"));
gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 0);
@@ -284,7 +293,7 @@ gimp_hue_saturation_tool_dialog (GimpImageMapTool *image_map_tool)
gtk_widget_show (table);
/* Create the 'Overlap' option slider */
- scale = gimp_prop_spin_scale_new (image_map_tool->config, "overlap",
+ scale = gimp_prop_spin_scale_new (im_tool->config, "overlap",
_("_Overlap"), 0.01, 0.1, 0);
gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
@@ -299,21 +308,21 @@ gimp_hue_saturation_tool_dialog (GimpImageMapTool *image_map_tool)
gtk_widget_show (vbox);
/* Create the hue scale widget */
- scale = gimp_prop_spin_scale_new (image_map_tool->config, "hue",
+ scale = gimp_prop_spin_scale_new (im_tool->config, "hue",
_("_Hue"), 1.0 / 180.0, 15.0 / 180.0, 0);
gimp_prop_widget_set_factor (scale, 180.0, 0.0, 0.0, 1);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
gtk_widget_show (scale);
/* Create the lightness scale widget */
- scale = gimp_prop_spin_scale_new (image_map_tool->config, "lightness",
+ scale = gimp_prop_spin_scale_new (im_tool->config, "lightness",
_("_Lightness"), 0.01, 0.1, 0);
gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
gtk_widget_show (scale);
/* Create the saturation scale widget */
- scale = gimp_prop_spin_scale_new (image_map_tool->config, "saturation",
+ scale = gimp_prop_spin_scale_new (im_tool->config, "saturation",
_("_Saturation"), 0.01, 0.1, 0);
gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
@@ -338,29 +347,32 @@ gimp_hue_saturation_tool_dialog (GimpImageMapTool *image_map_tool)
}
static void
-gimp_hue_saturation_tool_reset (GimpImageMapTool *image_map_tool)
+gimp_hue_saturation_tool_reset (GimpImageMapTool *im_tool)
{
- GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (image_map_tool);
- GimpHueRange range = hs_tool->config->range;
+ GimpHueRange range;
+
+ g_object_freeze_notify (im_tool->config);
- g_object_freeze_notify (image_map_tool->config);
+ g_object_get (im_tool->config,
+ "range", &range,
+ NULL);
- if (image_map_tool->default_config)
+ if (im_tool->default_config)
{
- gimp_config_copy (GIMP_CONFIG (image_map_tool->default_config),
- GIMP_CONFIG (image_map_tool->config),
+ gimp_config_copy (GIMP_CONFIG (im_tool->default_config),
+ GIMP_CONFIG (im_tool->config),
0);
}
else
{
- gimp_config_reset (GIMP_CONFIG (image_map_tool->config));
+ gimp_config_reset (GIMP_CONFIG (im_tool->config));
}
- g_object_set (hs_tool->config,
+ g_object_set (im_tool->config,
"range", range,
NULL);
- g_object_thaw_notify (image_map_tool->config);
+ g_object_thaw_notify (im_tool->config);
}
static void
@@ -395,13 +407,15 @@ hue_saturation_update_color_areas (GimpHueSaturationTool *hs_tool)
{ 1.0, 0, 1.0, }
};
- gint i;
+ GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (hs_tool);
+ GimpHueSaturationConfig *config = GIMP_HUE_SATURATION_CONFIG (im_tool->config);
+ gint i;
for (i = 0; i < 6; i++)
{
GimpRGB color = default_colors[i];
- gimp_operation_hue_saturation_map (hs_tool->config, &color, i + 1,
+ gimp_operation_hue_saturation_map (config, &color, i + 1,
&color);
gimp_color_area_set_color (GIMP_COLOR_AREA (hs_tool->hue_range_color_area[i]),
@@ -410,23 +424,23 @@ hue_saturation_update_color_areas (GimpHueSaturationTool *hs_tool)
}
static void
-hue_saturation_range_callback (GtkWidget *widget,
- GimpHueSaturationTool *hs_tool)
+hue_saturation_range_callback (GtkWidget *widget,
+ GimpImageMapTool *im_tool)
{
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
{
GimpHueRange range;
gimp_radio_button_update (widget, &range);
- g_object_set (hs_tool->config,
+ g_object_set (im_tool->config,
"range", range,
NULL);
}
}
static void
-hue_saturation_range_reset_callback (GtkWidget *widget,
- GimpHueSaturationTool *hs_tool)
+hue_saturation_range_reset_callback (GtkWidget *widget,
+ GimpImageMapTool *im_tool)
{
- gimp_hue_saturation_config_reset_range (hs_tool->config);
+ gimp_hue_saturation_config_reset_range (GIMP_HUE_SATURATION_CONFIG (im_tool->config));
}
diff --git a/app/tools/gimphuesaturationtool.h b/app/tools/gimphuesaturationtool.h
index 939d115..9cbf90f 100644
--- a/app/tools/gimphuesaturationtool.h
+++ b/app/tools/gimphuesaturationtool.h
@@ -35,13 +35,11 @@ typedef struct _GimpHueSaturationToolClass GimpHueSaturationToolClass;
struct _GimpHueSaturationTool
{
- GimpImageMapTool parent_instance;
-
- GimpHueSaturationConfig *config;
+ GimpImageMapTool parent_instance;
/* dialog */
- GtkWidget *range_radio;
- GtkWidget *hue_range_color_area[6];
+ GtkWidget *range_radio;
+ GtkWidget *hue_range_color_area[6];
};
struct _GimpHueSaturationToolClass
diff --git a/app/tools/gimpimagemaptool.c b/app/tools/gimpimagemaptool.c
index f69810b..603e657 100644
--- a/app/tools/gimpimagemaptool.c
+++ b/app/tools/gimpimagemaptool.c
@@ -38,6 +38,8 @@
#include "config/gimpguiconfig.h"
+#include "gegl/gimp-gegl-config.h"
+
#include "core/gimp.h"
#include "core/gimpdrawable.h"
#include "core/gimperror.h"
@@ -179,13 +181,11 @@ gimp_image_map_tool_class_init (GimpImageMapToolClass *klass)
color_tool_class->pick = gimp_image_map_tool_pick_color;
color_tool_class->picked = gimp_image_map_tool_color_picked;
- klass->dialog_desc = NULL;
klass->settings_name = NULL;
klass->import_dialog_title = NULL;
klass->export_dialog_title = NULL;
klass->get_operation = NULL;
- klass->map = NULL;
klass->dialog = NULL;
klass->reset = gimp_image_map_tool_real_reset;
klass->get_settings_ui = gimp_image_map_tool_real_get_settings_ui;
@@ -249,12 +249,36 @@ gimp_image_map_tool_finalize (GObject *object)
image_map_tool->default_config = NULL;
}
+ if (image_map_tool->title)
+ {
+ g_free (image_map_tool->title);
+ image_map_tool->title = NULL;
+ }
+
+ if (image_map_tool->description)
+ {
+ g_free (image_map_tool->description);
+ image_map_tool->description = NULL;
+ }
+
if (image_map_tool->undo_desc)
{
g_free (image_map_tool->undo_desc);
image_map_tool->undo_desc = NULL;
}
+ if (image_map_tool->icon_name)
+ {
+ g_free (image_map_tool->icon_name);
+ image_map_tool->icon_name = NULL;
+ }
+
+ if (image_map_tool->help_id)
+ {
+ g_free (image_map_tool->help_id);
+ image_map_tool->help_id = NULL;
+ }
+
if (image_map_tool->label_group)
{
g_object_unref (image_map_tool->label_group);
@@ -290,11 +314,11 @@ gimp_image_map_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error)
{
- GimpImageMapTool *image_map_tool = GIMP_IMAGE_MAP_TOOL (tool);
- GimpToolInfo *tool_info = tool->tool_info;
- GimpImage *image = gimp_display_get_image (display);
- GimpDrawable *drawable = gimp_image_get_active_drawable (image);
- GimpDisplayShell *shell = gimp_display_get_shell (display);
+ GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (tool);
+ GimpToolInfo *tool_info = tool->tool_info;
+ GimpImage *image = gimp_display_get_image (display);
+ GimpDrawable *drawable = gimp_image_get_active_drawable (image);
+ GimpDisplayShell *shell = gimp_display_get_shell (display);
if (! drawable)
return FALSE;
@@ -320,34 +344,32 @@ gimp_image_map_tool_initialize (GimpTool *tool,
return FALSE;
}
- if (image_map_tool->active_picker)
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (image_map_tool->active_picker),
+ if (im_tool->active_picker)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (im_tool->active_picker),
FALSE);
/* set display so the dialog can be hidden on display destruction */
tool->display = display;
- if (image_map_tool->config)
- gimp_config_reset (GIMP_CONFIG (image_map_tool->config));
+ if (im_tool->config)
+ gimp_config_reset (GIMP_CONFIG (im_tool->config));
- if (! image_map_tool->gui)
+ if (! im_tool->gui)
{
- GimpImageMapToolClass *klass;
+ GimpImageMapToolClass *klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (im_tool);
GtkWidget *vbox;
GtkWidget *toggle;
gchar *operation_name;
- klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (image_map_tool);
-
/* disabled for at least GIMP 2.8 */
- image_map_tool->overlay = FALSE;
+ im_tool->overlay = FALSE;
- image_map_tool->gui =
+ im_tool->gui =
gimp_tool_gui_new (tool_info,
- klass->dialog_desc,
+ im_tool->description,
gtk_widget_get_screen (GTK_WIDGET (shell)),
gimp_widget_get_monitor (GTK_WIDGET (shell)),
- image_map_tool->overlay,
+ im_tool->overlay,
GIMP_STOCK_RESET, RESPONSE_RESET,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
@@ -355,21 +377,21 @@ gimp_image_map_tool_initialize (GimpTool *tool,
NULL);
- gimp_tool_gui_set_default_response (image_map_tool->gui, GTK_RESPONSE_OK);
+ gimp_tool_gui_set_default_response (im_tool->gui, GTK_RESPONSE_OK);
- gimp_tool_gui_set_alternative_button_order (image_map_tool->gui,
+ gimp_tool_gui_set_alternative_button_order (im_tool->gui,
RESPONSE_RESET,
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
- vbox = gimp_tool_gui_get_vbox (image_map_tool->gui);
+ vbox = gimp_tool_gui_get_vbox (im_tool->gui);
- g_signal_connect_object (image_map_tool->gui, "response",
+ g_signal_connect_object (im_tool->gui, "response",
G_CALLBACK (gimp_image_map_tool_response),
- G_OBJECT (image_map_tool), 0);
+ G_OBJECT (im_tool), 0);
- if (image_map_tool->config && klass->settings_name)
+ if (im_tool->config && klass->settings_name)
{
GtkWidget *settings_ui;
GFile *default_folder;
@@ -379,14 +401,14 @@ gimp_image_map_tool_initialize (GimpTool *tool,
".settings");
default_folder = gimp_directory_file (klass->settings_name, NULL);
- settings_ui = klass->get_settings_ui (image_map_tool,
+ settings_ui = klass->get_settings_ui (im_tool,
klass->recent_settings,
settings_file,
klass->import_dialog_title,
klass->export_dialog_title,
- tool_info->help_id,
+ im_tool->help_id,
default_folder,
- &image_map_tool->settings_box);
+ &im_tool->settings_box);
g_object_unref (default_folder);
g_object_unref (settings_file);
@@ -402,7 +424,7 @@ gimp_image_map_tool_initialize (GimpTool *tool,
g_signal_connect (toggle, "toggled",
G_CALLBACK (gamma_hack),
- image_map_tool);
+ im_tool);
/* The preview toggle */
toggle = gimp_prop_check_button_new (G_OBJECT (tool_info->tool_options),
@@ -412,38 +434,49 @@ gimp_image_map_tool_initialize (GimpTool *tool,
gtk_widget_show (toggle);
/* The area combo */
- gegl_node_get (image_map_tool->operation,
+ gegl_node_get (im_tool->operation,
"operation", &operation_name,
NULL);
- image_map_tool->region_combo =
+ im_tool->region_combo =
gimp_prop_enum_combo_box_new (G_OBJECT (tool_info->tool_options),
"region",
0, 0);
- gtk_box_pack_end (GTK_BOX (vbox), image_map_tool->region_combo,
+ gtk_box_pack_end (GTK_BOX (vbox), im_tool->region_combo,
FALSE, FALSE, 0);
if (operation_name &&
gegl_operation_get_key (operation_name, "position-dependent"))
{
- gtk_widget_show (image_map_tool->region_combo);
+ gtk_widget_show (im_tool->region_combo);
}
g_free (operation_name);
/* Fill in subclass widgets */
- gimp_image_map_tool_dialog (image_map_tool);
+ gimp_image_map_tool_dialog (im_tool);
+ }
+ else
+ {
+ gimp_tool_gui_set_description (im_tool->gui, im_tool->description);
}
- gimp_tool_gui_set_shell (image_map_tool->gui, shell);
- gimp_tool_gui_set_viewable (image_map_tool->gui, GIMP_VIEWABLE (drawable));
+ /* FIXME move these into the block above once gimp_tool_gui_new()
+ * got more arguments
+ */
+ gimp_tool_gui_set_title (im_tool->gui, im_tool->title);
+ gimp_tool_gui_set_icon_name (im_tool->gui, im_tool->icon_name);
+ gimp_tool_gui_set_help_id (im_tool->gui, im_tool->help_id);
- gimp_tool_gui_show (image_map_tool->gui);
+ gimp_tool_gui_set_shell (im_tool->gui, shell);
+ gimp_tool_gui_set_viewable (im_tool->gui, GIMP_VIEWABLE (drawable));
- image_map_tool->drawable = drawable;
+ gimp_tool_gui_show (im_tool->gui);
- gimp_image_map_tool_create_map (image_map_tool);
- gimp_image_map_tool_preview (image_map_tool);
+ im_tool->drawable = drawable;
+
+ gimp_image_map_tool_create_map (im_tool);
+ gimp_image_map_tool_preview (im_tool);
return TRUE;
}
@@ -453,7 +486,7 @@ gimp_image_map_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *display)
{
- GimpImageMapTool *image_map_tool = GIMP_IMAGE_MAP_TOOL (tool);
+ GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (tool);
switch (action)
{
@@ -462,11 +495,11 @@ gimp_image_map_tool_control (GimpTool *tool,
break;
case GIMP_TOOL_ACTION_HALT:
- gimp_image_map_tool_halt (image_map_tool);
+ gimp_image_map_tool_halt (im_tool);
break;
case GIMP_TOOL_ACTION_COMMIT:
- gimp_image_map_tool_commit (image_map_tool);
+ gimp_image_map_tool_commit (im_tool);
break;
}
@@ -478,30 +511,30 @@ gimp_image_map_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *display)
{
- GimpImageMapTool *image_map_tool = GIMP_IMAGE_MAP_TOOL (tool);
+ GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (tool);
- if (image_map_tool->gui && display == tool->display)
+ if (im_tool->gui && display == tool->display)
{
switch (kevent->keyval)
{
case GDK_KEY_Return:
case GDK_KEY_KP_Enter:
case GDK_KEY_ISO_Enter:
- gimp_image_map_tool_response (image_map_tool->gui,
+ gimp_image_map_tool_response (im_tool->gui,
GTK_RESPONSE_OK,
- image_map_tool);
+ im_tool);
return TRUE;
case GDK_KEY_BackSpace:
- gimp_image_map_tool_response (image_map_tool->gui,
+ gimp_image_map_tool_response (im_tool->gui,
RESPONSE_RESET,
- image_map_tool);
+ im_tool);
return TRUE;
case GDK_KEY_Escape:
- gimp_image_map_tool_response (image_map_tool->gui,
+ gimp_image_map_tool_response (im_tool->gui,
GTK_RESPONSE_CANCEL,
- image_map_tool);
+ im_tool);
return TRUE;
}
}
@@ -514,17 +547,17 @@ gimp_image_map_tool_options_notify (GimpTool *tool,
GimpToolOptions *options,
const GParamSpec *pspec)
{
- GimpImageMapTool *image_map_tool = GIMP_IMAGE_MAP_TOOL (tool);
- GimpImageMapOptions *im_options = GIMP_IMAGE_MAP_OPTIONS (options);
+ GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (tool);
+ GimpImageMapOptions *im_options = GIMP_IMAGE_MAP_OPTIONS (options);
if (! strcmp (pspec->name, "preview") &&
- image_map_tool->image_map)
+ im_tool->image_map)
{
if (im_options->preview)
{
gimp_tool_control_push_preserve (tool->control, TRUE);
- gimp_image_map_tool_map (image_map_tool);
+ gimp_image_map_tool_map (im_tool);
gimp_tool_control_pop_preserve (tool->control);
}
@@ -532,16 +565,16 @@ gimp_image_map_tool_options_notify (GimpTool *tool,
{
gimp_tool_control_push_preserve (tool->control, TRUE);
- gimp_image_map_abort (image_map_tool->image_map);
+ gimp_image_map_abort (im_tool->image_map);
gimp_tool_control_pop_preserve (tool->control);
}
}
else if (! strcmp (pspec->name, "region") &&
- image_map_tool->image_map)
+ im_tool->image_map)
{
- gimp_image_map_set_region (image_map_tool->image_map, im_options->region);
- gimp_image_map_tool_preview (image_map_tool);
+ gimp_image_map_set_region (im_tool->image_map, im_options->region);
+ gimp_image_map_tool_preview (im_tool);
}
}
@@ -553,14 +586,14 @@ gimp_image_map_tool_pick_color (GimpColorTool *color_tool,
gpointer pixel,
GimpRGB *color)
{
- GimpImageMapTool *tool = GIMP_IMAGE_MAP_TOOL (color_tool);
+ GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (color_tool);
gint off_x, off_y;
- gimp_item_get_offset (GIMP_ITEM (tool->drawable), &off_x, &off_y);
+ gimp_item_get_offset (GIMP_ITEM (im_tool->drawable), &off_x, &off_y);
- *sample_format = gimp_drawable_get_format (tool->drawable);
+ *sample_format = gimp_drawable_get_format (im_tool->drawable);
- return gimp_pickable_pick_color (GIMP_PICKABLE (tool->drawable),
+ return gimp_pickable_pick_color (GIMP_PICKABLE (im_tool->drawable),
x - off_x,
y - off_y,
color_tool->options->sample_average,
@@ -577,19 +610,19 @@ gimp_image_map_tool_color_picked (GimpColorTool *color_tool,
gpointer pixel,
const GimpRGB *color)
{
- GimpImageMapTool *tool = GIMP_IMAGE_MAP_TOOL (color_tool);
+ GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (color_tool);
gpointer identifier;
- g_return_if_fail (GTK_IS_WIDGET (tool->active_picker));
+ g_return_if_fail (GTK_IS_WIDGET (im_tool->active_picker));
- identifier = g_object_get_data (G_OBJECT (tool->active_picker),
+ identifier = g_object_get_data (G_OBJECT (im_tool->active_picker),
"picker-identifier");
- GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->color_picked (tool,
- identifier,
- x, y,
- sample_format,
- color);
+ GIMP_IMAGE_MAP_TOOL_GET_CLASS (im_tool)->color_picked (im_tool,
+ identifier,
+ x, y,
+ sample_format,
+ color);
}
static void
@@ -673,8 +706,8 @@ gimp_image_map_tool_commit (GimpImageMapTool *im_tool)
static void
gimp_image_map_tool_map (GimpImageMapTool *tool)
{
- if (GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->map)
- GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->map (tool);
+ gimp_gegl_config_sync_node (GIMP_OBJECT (tool->config),
+ tool->operation);
gimp_image_map_apply (tool->image_map, NULL);
}
@@ -713,8 +746,7 @@ gimp_image_map_tool_reset (GimpImageMapTool *tool)
static void
gimp_image_map_tool_create_map (GimpImageMapTool *tool)
{
- GimpImageMapOptions *options = GIMP_IMAGE_MAP_TOOL_GET_OPTIONS (tool);
- GimpToolInfo *tool_info = GIMP_TOOL (tool)->tool_info;
+ GimpImageMapOptions *options = GIMP_IMAGE_MAP_TOOL_GET_OPTIONS (tool);
if (tool->image_map)
{
@@ -727,7 +759,7 @@ gimp_image_map_tool_create_map (GimpImageMapTool *tool)
tool->image_map = gimp_image_map_new (tool->drawable,
tool->undo_desc,
tool->operation,
- gimp_viewable_get_icon_name (GIMP_VIEWABLE (tool_info)));
+ tool->icon_name);
gimp_image_map_set_region (tool->image_map, options->region);
@@ -738,9 +770,9 @@ gimp_image_map_tool_create_map (GimpImageMapTool *tool)
static void
gimp_image_map_tool_flush (GimpImageMap *image_map,
- GimpImageMapTool *image_map_tool)
+ GimpImageMapTool *im_tool)
{
- GimpTool *tool = GIMP_TOOL (image_map_tool);
+ GimpTool *tool = GIMP_TOOL (im_tool);
GimpImage *image = gimp_display_get_image (tool->display);
gimp_projection_flush (gimp_image_get_projection (image));
@@ -749,23 +781,23 @@ gimp_image_map_tool_flush (GimpImageMap *image_map,
static void
gimp_image_map_tool_config_notify (GObject *object,
const GParamSpec *pspec,
- GimpImageMapTool *image_map_tool)
+ GimpImageMapTool *im_tool)
{
- gimp_image_map_tool_preview (image_map_tool);
+ gimp_image_map_tool_preview (im_tool);
}
static void
gimp_image_map_tool_response (GimpToolGui *gui,
gint response_id,
- GimpImageMapTool *image_map_tool)
+ GimpImageMapTool *im_tool)
{
- GimpTool *tool = GIMP_TOOL (image_map_tool);
+ GimpTool *tool = GIMP_TOOL (im_tool);
switch (response_id)
{
case RESPONSE_RESET:
- gimp_image_map_tool_reset (image_map_tool);
- gimp_image_map_tool_preview (image_map_tool);
+ gimp_image_map_tool_reset (im_tool);
+ gimp_image_map_tool_preview (im_tool);
break;
case GTK_RESPONSE_OK:
@@ -779,99 +811,158 @@ gimp_image_map_tool_response (GimpToolGui *gui,
}
void
-gimp_image_map_tool_get_operation (GimpImageMapTool *image_map_tool)
+gimp_image_map_tool_get_operation (GimpImageMapTool *im_tool)
{
GimpImageMapToolClass *klass;
+ GimpToolInfo *tool_info;
gchar *operation_name;
- g_return_if_fail (GIMP_IS_IMAGE_MAP_TOOL (image_map_tool));
+ g_return_if_fail (GIMP_IS_IMAGE_MAP_TOOL (im_tool));
+
+ klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (im_tool);
- klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (image_map_tool);
+ tool_info = GIMP_TOOL (im_tool)->tool_info;
- if (image_map_tool->image_map)
+ if (im_tool->image_map)
{
- gimp_image_map_abort (image_map_tool->image_map);
- g_object_unref (image_map_tool->image_map);
- image_map_tool->image_map = NULL;
+ gimp_image_map_abort (im_tool->image_map);
+ g_object_unref (im_tool->image_map);
+ im_tool->image_map = NULL;
}
- if (image_map_tool->operation)
+ if (im_tool->operation)
{
- g_object_unref (image_map_tool->operation);
- image_map_tool->operation = NULL;
+ g_object_unref (im_tool->operation);
+ im_tool->operation = NULL;
}
- if (image_map_tool->config)
+ if (im_tool->config)
{
- g_signal_handlers_disconnect_by_func (image_map_tool->config,
+ g_signal_handlers_disconnect_by_func (im_tool->config,
gimp_image_map_tool_config_notify,
- image_map_tool);
+ im_tool);
- g_object_unref (image_map_tool->config);
- image_map_tool->config = NULL;
+ g_object_unref (im_tool->config);
+ im_tool->config = NULL;
}
- if (image_map_tool->undo_desc)
+ if (im_tool->title)
{
- g_free (image_map_tool->undo_desc);
- image_map_tool->undo_desc = NULL;
+ g_free (im_tool->title);
+ im_tool->title = NULL;
}
- image_map_tool->operation = klass->get_operation (image_map_tool,
- &image_map_tool->config,
- &image_map_tool->undo_desc);
+ if (im_tool->description)
+ {
+ g_free (im_tool->description);
+ im_tool->description = NULL;
+ }
+
+ if (im_tool->undo_desc)
+ {
+ g_free (im_tool->undo_desc);
+ im_tool->undo_desc = NULL;
+ }
- if (! image_map_tool->undo_desc)
- image_map_tool->undo_desc =
- g_strdup (GIMP_TOOL (image_map_tool)->tool_info->blurb);
+ if (im_tool->icon_name)
+ {
+ g_free (im_tool->icon_name);
+ im_tool->icon_name = NULL;
+ }
- gegl_node_get (image_map_tool->operation,
- "operation", &operation_name,
- NULL);
+ if (im_tool->help_id)
+ {
+ g_free (im_tool->help_id);
+ im_tool->help_id = NULL;
+ }
+
+ operation_name = klass->get_operation (im_tool,
+ &im_tool->title,
+ &im_tool->description,
+ &im_tool->undo_desc,
+ &im_tool->icon_name,
+ &im_tool->help_id);
+
+ if (! operation_name)
+ operation_name = g_strdup ("gegl:nop");
+
+ if (! im_tool->title)
+ im_tool->title = g_strdup (tool_info->blurb);
+
+ if (! im_tool->description)
+ im_tool->description = g_strdup (im_tool->title);
+
+ if (! im_tool->undo_desc)
+ im_tool->undo_desc = g_strdup (tool_info->blurb);
+
+ if (! im_tool->icon_name)
+ im_tool->icon_name =
+ g_strdup (gimp_viewable_get_icon_name (GIMP_VIEWABLE (tool_info)));
+
+ if (! im_tool->help_id)
+ im_tool->help_id = g_strdup (tool_info->help_id);
+
+ im_tool->operation = gegl_node_new_child (NULL,
+ "operation", operation_name,
+ NULL);
+ im_tool->config = G_OBJECT (gimp_gegl_config_new (operation_name,
+ im_tool->icon_name,
+ GIMP_TYPE_SETTINGS));
+
+ gimp_gegl_config_sync_node (GIMP_OBJECT (im_tool->config),
+ im_tool->operation);
+
+ if (im_tool->gui)
+ {
+ gimp_tool_gui_set_title (im_tool->gui, im_tool->title);
+ gimp_tool_gui_set_description (im_tool->gui, im_tool->description);
+ gimp_tool_gui_set_icon_name (im_tool->gui, im_tool->icon_name);
+ gimp_tool_gui_set_help_id (im_tool->gui, im_tool->help_id);
+ }
if (operation_name &&
gegl_operation_get_key (operation_name, "position-dependent"))
{
- if (image_map_tool->region_combo)
- gtk_widget_show (image_map_tool->region_combo);
+ if (im_tool->gui)
+ gtk_widget_show (im_tool->region_combo);
}
else
{
- if (image_map_tool->region_combo)
- gtk_widget_hide (image_map_tool->region_combo);
+ if (im_tool->gui)
+ gtk_widget_hide (im_tool->region_combo);
- g_object_set (GIMP_IMAGE_MAP_TOOL_GET_OPTIONS (image_map_tool),
+ g_object_set (GIMP_IMAGE_MAP_TOOL_GET_OPTIONS (im_tool),
"region", GIMP_IMAGE_MAP_REGION_SELECTION,
NULL);
}
g_free (operation_name);
- if (image_map_tool->config)
- g_signal_connect_object (image_map_tool->config, "notify",
+ if (im_tool->config)
+ g_signal_connect_object (im_tool->config, "notify",
G_CALLBACK (gimp_image_map_tool_config_notify),
- G_OBJECT (image_map_tool), 0);
+ G_OBJECT (im_tool), 0);
- if (GIMP_TOOL (image_map_tool)->drawable)
- gimp_image_map_tool_create_map (image_map_tool);
+ if (GIMP_TOOL (im_tool)->drawable)
+ gimp_image_map_tool_create_map (im_tool);
}
void
-gimp_image_map_tool_preview (GimpImageMapTool *image_map_tool)
+gimp_image_map_tool_preview (GimpImageMapTool *im_tool)
{
GimpTool *tool;
GimpImageMapOptions *options;
- g_return_if_fail (GIMP_IS_IMAGE_MAP_TOOL (image_map_tool));
+ g_return_if_fail (GIMP_IS_IMAGE_MAP_TOOL (im_tool));
- tool = GIMP_TOOL (image_map_tool);
+ tool = GIMP_TOOL (im_tool);
options = GIMP_IMAGE_MAP_TOOL_GET_OPTIONS (tool);
- if (image_map_tool->image_map && options->preview)
+ if (im_tool->image_map && options->preview)
{
gimp_tool_control_push_preserve (tool->control, TRUE);
- gimp_image_map_tool_map (image_map_tool);
+ gimp_image_map_tool_map (im_tool);
gimp_tool_control_pop_preserve (tool->control);
}
diff --git a/app/tools/gimpimagemaptool.h b/app/tools/gimpimagemaptool.h
index c9eba3e..4296733 100644
--- a/app/tools/gimpimagemaptool.h
+++ b/app/tools/gimpimagemaptool.h
@@ -43,7 +43,12 @@ struct _GimpImageMapTool
GeglNode *operation;
GObject *config;
GObject *default_config;
+
+ gchar *title;
+ gchar *description;
gchar *undo_desc;
+ gchar *icon_name;
+ gchar *help_id;
GimpImageMap *image_map;
@@ -60,7 +65,6 @@ struct _GimpImageMapToolClass
{
GimpColorToolClass parent_class;
- const gchar *dialog_desc;
const gchar *settings_name;
const gchar *import_dialog_title;
const gchar *export_dialog_title;
@@ -68,10 +72,12 @@ struct _GimpImageMapToolClass
GimpContainer *recent_settings;
/* virtual functions */
- GeglNode * (* get_operation) (GimpImageMapTool *image_map_tool,
- GObject **config,
- gchar **undo_desc);
- void (* map) (GimpImageMapTool *image_map_tool);
+ gchar * (* get_operation) (GimpImageMapTool *image_map_tool,
+ gchar **title,
+ gchar **description,
+ gchar **undo_desc,
+ gchar **icon_name,
+ gchar **help_id);
void (* dialog) (GimpImageMapTool *image_map_tool);
void (* reset) (GimpImageMapTool *image_map_tool);
diff --git a/app/tools/gimplevelstool.c b/app/tools/gimplevelstool.c
index 38688b2..c72b7f1 100644
--- a/app/tools/gimplevelstool.c
+++ b/app/tools/gimplevelstool.c
@@ -65,15 +65,19 @@
/* local function prototypes */
+static void gimp_levels_tool_constructed (GObject *object);
static void gimp_levels_tool_finalize (GObject *object);
static gboolean gimp_levels_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error);
-static GeglNode * gimp_levels_tool_get_operation (GimpImageMapTool *im_tool,
- GObject **config,
- gchar **undo_desc);
+static gchar * gimp_levels_tool_get_operation (GimpImageMapTool *im_tool,
+ gchar **title,
+ gchar **description,
+ gchar **undo_desc,
+ gchar **icon_name,
+ gchar **help_id);
static void gimp_levels_tool_dialog (GimpImageMapTool *im_tool);
static void gimp_levels_tool_reset (GimpImageMapTool *im_tool);
static gboolean gimp_levels_tool_settings_import(GimpImageMapTool *im_tool,
@@ -100,9 +104,9 @@ static void gimp_levels_tool_config_notify (GObject *object,
static void levels_update_input_bar (GimpLevelsTool *tool);
static void levels_channel_callback (GtkWidget *widget,
- GimpLevelsTool *tool);
+ GimpImageMapTool *im_tool);
static void levels_channel_reset_callback (GtkWidget *widget,
- GimpLevelsTool *tool);
+ GimpImageMapTool *im_tool);
static gboolean levels_menu_sensitivity (gint value,
gpointer data);
@@ -113,7 +117,7 @@ static void levels_linear_gamma_changed (GtkAdjustment *adjustment
GimpLevelsTool *tool);
static void levels_to_curves_callback (GtkWidget *widget,
- GimpLevelsTool *tool);
+ GimpImageMapTool *im_tool);
G_DEFINE_TYPE (GimpLevelsTool, gimp_levels_tool, GIMP_TYPE_IMAGE_MAP_TOOL)
@@ -145,11 +149,11 @@ gimp_levels_tool_class_init (GimpLevelsToolClass *klass)
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
+ object_class->constructed = gimp_levels_tool_constructed;
object_class->finalize = gimp_levels_tool_finalize;
tool_class->initialize = gimp_levels_tool_initialize;
- im_tool_class->dialog_desc = _("Adjust Color Levels");
im_tool_class->settings_name = "levels";
im_tool_class->import_dialog_title = _("Import Levels");
im_tool_class->export_dialog_title = _("Export Levels");
@@ -169,6 +173,16 @@ gimp_levels_tool_init (GimpLevelsTool *tool)
}
static void
+gimp_levels_tool_constructed (GObject *object)
+{
+ G_OBJECT_CLASS (parent_class)->constructed (object);
+
+ g_signal_connect_object (GIMP_IMAGE_MAP_TOOL (object)->config, "notify",
+ G_CALLBACK (gimp_levels_tool_config_notify),
+ object, 0);
+}
+
+static void
gimp_levels_tool_finalize (GObject *object)
{
GimpLevelsTool *tool = GIMP_LEVELS_TOOL (object);
@@ -242,25 +256,17 @@ gimp_levels_tool_initialize (GimpTool *tool,
return TRUE;
}
-static GeglNode *
+static gchar *
gimp_levels_tool_get_operation (GimpImageMapTool *im_tool,
- GObject **config,
- gchar **undo_desc)
+ gchar **title,
+ gchar **description,
+ gchar **undo_desc,
+ gchar **icon_name,
+ gchar **help_id)
{
- GimpLevelsTool *tool = GIMP_LEVELS_TOOL (im_tool);
-
- tool->config = g_object_new (GIMP_TYPE_LEVELS_CONFIG, NULL);
-
- g_signal_connect_object (tool->config, "notify",
- G_CALLBACK (gimp_levels_tool_config_notify),
- G_OBJECT (tool), 0);
+ *description = g_strdup (_("Adjust Color Levels"));
- *config = G_OBJECT (tool->config);
-
- return gegl_node_new_child (NULL,
- "operation", "gimp:levels",
- "config", tool->config,
- NULL);
+ return g_strdup ("gimp:levels");
}
@@ -316,11 +322,11 @@ gimp_levels_tool_color_picker_new (GimpLevelsTool *tool,
}
static void
-gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
+gimp_levels_tool_dialog (GimpImageMapTool *im_tool)
{
- GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool);
- GimpToolOptions *tool_options = GIMP_TOOL_GET_OPTIONS (image_map_tool);
- GimpLevelsConfig *config = tool->config;
+ GimpLevelsTool *tool = GIMP_LEVELS_TOOL (im_tool);
+ GimpToolOptions *tool_options = GIMP_TOOL_GET_OPTIONS (im_tool);
+ GimpLevelsConfig *config = GIMP_LEVELS_CONFIG (im_tool->config);
GtkListStore *store;
GtkWidget *main_vbox;
GtkWidget *frame_vbox;
@@ -341,11 +347,11 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
GtkWidget *handle_bar;
gint border;
- g_signal_connect (image_map_tool->settings_box, "file-dialog-setup",
+ g_signal_connect (im_tool->settings_box, "file-dialog-setup",
G_CALLBACK (gimp_levels_tool_export_setup),
- image_map_tool);
+ im_tool);
- main_vbox = gimp_image_map_tool_dialog_get_vbox (image_map_tool);
+ main_vbox = gimp_image_map_tool_dialog_get_vbox (im_tool);
/* The option menu for selecting channels */
main_frame = gimp_frame_new (NULL);
@@ -466,7 +472,7 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
gtk_widget_show (button);
tool->low_input_spinbutton = spinbutton =
- gimp_prop_spin_button_new (image_map_tool->config, "low-input",
+ gimp_prop_spin_button_new (im_tool->config, "low-input",
0.01, 0.1, 1);
gtk_box_pack_start (GTK_BOX (hbox2), spinbutton, FALSE, FALSE, 0);
gtk_widget_show (spinbutton);
@@ -476,7 +482,7 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
tool->low_input);
/* input gamma spin */
- spinbutton = gimp_prop_spin_button_new (image_map_tool->config, "gamma",
+ spinbutton = gimp_prop_spin_button_new (im_tool->config, "gamma",
0.01, 0.1, 2);
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, TRUE, FALSE, 0);
gimp_help_set_help_data (spinbutton, _("Gamma"), NULL);
@@ -503,7 +509,7 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, FALSE, 0);
gtk_widget_show (button);
- spinbutton = gimp_prop_spin_button_new (image_map_tool->config, "high-input",
+ spinbutton = gimp_prop_spin_button_new (im_tool->config, "high-input",
0.01, 0.1, 1);
gtk_box_pack_start (GTK_BOX (hbox2), spinbutton, FALSE, FALSE, 0);
gtk_widget_show (spinbutton);
@@ -552,7 +558,7 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
/* low output spin */
tool->low_output_spinbutton = spinbutton =
- gimp_prop_spin_button_new (image_map_tool->config, "low-output",
+ gimp_prop_spin_button_new (im_tool->config, "low-output",
0.01, 0.1, 1);
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
gtk_widget_show (spinbutton);
@@ -562,7 +568,7 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
/* high output spin */
tool->high_output_spinbutton = spinbutton =
- gimp_prop_spin_button_new (image_map_tool->config, "high-output",
+ gimp_prop_spin_button_new (im_tool->config, "high-output",
0.01, 0.1, 1);
gtk_box_pack_end (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
gtk_widget_show (spinbutton);
@@ -624,26 +630,29 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
}
static void
-gimp_levels_tool_reset (GimpImageMapTool *image_map_tool)
+gimp_levels_tool_reset (GimpImageMapTool *im_tool)
{
- GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool);
- GimpHistogramChannel channel = tool->config->channel;
+ GimpHistogramChannel channel;
+
+ g_object_get (im_tool->config,
+ "channel", &channel,
+ NULL);
- GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->reset (image_map_tool);
+ GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->reset (im_tool);
- g_object_set (tool->config,
+ g_object_set (im_tool->config,
"channel", channel,
NULL);
}
static gboolean
-gimp_levels_tool_settings_import (GimpImageMapTool *image_map_tool,
+gimp_levels_tool_settings_import (GimpImageMapTool *im_tool,
GInputStream *input,
GError **error)
{
- GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool);
- gchar header[64];
- gsize bytes_read;
+ GimpLevelsConfig *config = GIMP_LEVELS_CONFIG (im_tool->config);
+ gchar header[64];
+ gsize bytes_read;
if (! g_input_stream_read_all (input, header, sizeof (header),
&bytes_read, NULL, error) ||
@@ -656,24 +665,25 @@ gimp_levels_tool_settings_import (GimpImageMapTool *image_map_tool,
g_seekable_seek (G_SEEKABLE (input), 0, G_SEEK_SET, NULL, NULL);
if (g_str_has_prefix (header, "# GIMP Levels File\n"))
- return gimp_levels_config_load_cruft (tool->config, input, error);
+ return gimp_levels_config_load_cruft (config, input, error);
- return GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->settings_import (image_map_tool,
+ return GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->settings_import (im_tool,
input,
error);
}
static gboolean
-gimp_levels_tool_settings_export (GimpImageMapTool *image_map_tool,
+gimp_levels_tool_settings_export (GimpImageMapTool *im_tool,
GOutputStream *output,
GError **error)
{
- GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool);
+ GimpLevelsTool *tool = GIMP_LEVELS_TOOL (im_tool);
+ GimpLevelsConfig *config = GIMP_LEVELS_CONFIG (im_tool->config);
if (tool->export_old_format)
- return gimp_levels_config_save_cruft (tool->config, output, error);
+ return gimp_levels_config_save_cruft (config, output, error);
- return GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->settings_export (image_map_tool,
+ return GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->settings_export (im_tool,
output,
error);
}
@@ -708,8 +718,9 @@ gimp_levels_tool_color_picked (GimpImageMapTool *color_tool,
const Babl *sample_format,
const GimpRGB *color)
{
- GimpLevelsTool *tool = GIMP_LEVELS_TOOL (color_tool);
- guint value = GPOINTER_TO_UINT (identifier);
+ GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (color_tool);
+ GimpLevelsConfig *config = GIMP_LEVELS_CONFIG (im_tool->config);
+ guint value = GPOINTER_TO_UINT (identifier);
if (value & PICK_ALL_CHANNELS &&
gimp_babl_format_get_base_type (sample_format) == GIMP_RGB)
@@ -720,13 +731,13 @@ gimp_levels_tool_color_picked (GimpImageMapTool *color_tool,
switch (value & 0xF)
{
case PICK_LOW_INPUT:
- tool->config->low_input[GIMP_HISTOGRAM_VALUE] = 0.0;
+ config->low_input[GIMP_HISTOGRAM_VALUE] = 0.0;
break;
case PICK_GAMMA:
- tool->config->gamma[GIMP_HISTOGRAM_VALUE] = 1.0;
+ config->gamma[GIMP_HISTOGRAM_VALUE] = 1.0;
break;
case PICK_HIGH_INPUT:
- tool->config->high_input[GIMP_HISTOGRAM_VALUE] = 1.0;
+ config->high_input[GIMP_HISTOGRAM_VALUE] = 1.0;
break;
default:
break;
@@ -737,14 +748,12 @@ gimp_levels_tool_color_picked (GimpImageMapTool *color_tool,
channel <= GIMP_HISTOGRAM_BLUE;
channel++)
{
- levels_input_adjust_by_color (tool->config,
- value, channel, color);
+ levels_input_adjust_by_color (config, value, channel, color);
}
}
else
{
- levels_input_adjust_by_color (tool->config,
- value, tool->config->channel, color);
+ levels_input_adjust_by_color (config, value, config->channel, color);
}
}
@@ -807,7 +816,7 @@ gimp_levels_tool_config_notify (GObject *object,
delta = (high - low) / 2.0;
mid = low + delta;
- tmp = log10 (1.0 / tool->config->gamma[tool->config->channel]);
+ tmp = log10 (1.0 / config->gamma[config->channel]);
value = mid + delta * tmp;
gtk_adjustment_set_value (tool->gamma_linear, value);
@@ -817,7 +826,8 @@ gimp_levels_tool_config_notify (GObject *object,
static void
levels_update_input_bar (GimpLevelsTool *tool)
{
- GimpLevelsConfig *config = tool->config;
+ GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (tool);
+ GimpLevelsConfig *config = GIMP_LEVELS_CONFIG (im_tool->config);
switch (config->channel)
{
@@ -878,25 +888,26 @@ levels_update_input_bar (GimpLevelsTool *tool)
}
static void
-levels_channel_callback (GtkWidget *widget,
- GimpLevelsTool *tool)
+levels_channel_callback (GtkWidget *widget,
+ GimpImageMapTool *im_tool)
{
- gint value;
+ GimpLevelsConfig *config = GIMP_LEVELS_CONFIG (im_tool->config);
+ gint value;
if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value) &&
- tool->config->channel != value)
+ config->channel != value)
{
- g_object_set (tool->config,
+ g_object_set (config,
"channel", value,
NULL);
}
}
static void
-levels_channel_reset_callback (GtkWidget *widget,
- GimpLevelsTool *tool)
+levels_channel_reset_callback (GtkWidget *widget,
+ GimpImageMapTool *im_tool)
{
- gimp_levels_config_reset_channel (tool->config);
+ gimp_levels_config_reset_channel (GIMP_LEVELS_CONFIG (im_tool->config));
}
static gboolean
@@ -930,10 +941,11 @@ static void
levels_stretch_callback (GtkWidget *widget,
GimpLevelsTool *tool)
{
- GimpDrawable *drawable = GIMP_IMAGE_MAP_TOOL (tool)->drawable;
+ GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (tool);
- gimp_levels_config_stretch (tool->config, tool->histogram,
- gimp_drawable_is_rgb (drawable));
+ gimp_levels_config_stretch (GIMP_LEVELS_CONFIG (im_tool->config),
+ tool->histogram,
+ gimp_drawable_is_rgb (im_tool->drawable));
}
static void
@@ -960,14 +972,15 @@ levels_linear_gamma_changed (GtkAdjustment *adjustment,
}
static void
-levels_to_curves_callback (GtkWidget *widget,
- GimpLevelsTool *tool)
+levels_to_curves_callback (GtkWidget *widget,
+ GimpImageMapTool *im_tool)
{
+ GimpLevelsConfig *config = GIMP_LEVELS_CONFIG (im_tool->config);
GimpCurvesConfig *curves;
- curves = gimp_levels_config_to_curves_config (tool->config);
+ curves = gimp_levels_config_to_curves_config (config);
- gimp_image_map_tool_edit_as (GIMP_IMAGE_MAP_TOOL (tool),
+ gimp_image_map_tool_edit_as (im_tool,
"gimp-curves-tool",
GIMP_CONFIG (curves));
diff --git a/app/tools/gimplevelstool.h b/app/tools/gimplevelstool.h
index 0ef8bdd..229539b 100644
--- a/app/tools/gimplevelstool.h
+++ b/app/tools/gimplevelstool.h
@@ -37,8 +37,6 @@ struct _GimpLevelsTool
{
GimpImageMapTool parent_instance;
- GimpLevelsConfig *config;
-
/* dialog */
GimpHistogram *histogram;
diff --git a/app/tools/gimpoperationtool.c b/app/tools/gimpoperationtool.c
index 424faf2..6562e42 100644
--- a/app/tools/gimpoperationtool.c
+++ b/app/tools/gimpoperationtool.c
@@ -78,10 +78,12 @@ static void gimp_operation_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *display);
-static GeglNode * gimp_operation_tool_get_operation (GimpImageMapTool *im_tool,
- GObject **config,
- gchar **undo_desc);
-static void gimp_operation_tool_map (GimpImageMapTool *im_tool);
+static gchar * gimp_operation_tool_get_operation (GimpImageMapTool *im_tool,
+ gchar **title,
+ gchar **description,
+ gchar **undo_desc,
+ gchar **icon_name,
+ gchar **help_id);
static void gimp_operation_tool_dialog (GimpImageMapTool *im_tool);
static void gimp_operation_tool_reset (GimpImageMapTool *im_tool);
static GtkWidget * gimp_operation_tool_get_settings_ui (GimpImageMapTool *im_tool,
@@ -146,10 +148,7 @@ gimp_operation_tool_class_init (GimpOperationToolClass *klass)
tool_class->initialize = gimp_operation_tool_initialize;
tool_class->control = gimp_operation_tool_control;
- im_tool_class->dialog_desc = _("GEGL Operation");
-
im_tool_class->get_operation = gimp_operation_tool_get_operation;
- im_tool_class->map = gimp_operation_tool_map;
im_tool_class->dialog = gimp_operation_tool_dialog;
im_tool_class->reset = gimp_operation_tool_reset;
im_tool_class->get_settings_ui = gimp_operation_tool_get_settings_ui;
@@ -179,6 +178,12 @@ gimp_operation_tool_finalize (GObject *object)
tool->title = NULL;
}
+ if (tool->description)
+ {
+ g_free (tool->description);
+ tool->description = NULL;
+ }
+
if (tool->undo_desc)
{
g_free (tool->undo_desc);
@@ -250,37 +255,23 @@ gimp_operation_tool_control (GimpTool *tool,
GIMP_TOOL_CLASS (parent_class)->control (tool, action, display);
}
-static GeglNode *
+static gchar *
gimp_operation_tool_get_operation (GimpImageMapTool *im_tool,
- GObject **config,
- gchar **undo_desc)
+ gchar **title,
+ gchar **description,
+ gchar **undo_desc,
+ gchar **icon_name,
+ gchar **help_id)
{
GimpOperationTool *tool = GIMP_OPERATION_TOOL (im_tool);
- if (tool->operation)
- *config = G_OBJECT (gimp_gegl_config_new (tool->operation,
- tool->icon_name,
- GIMP_TYPE_SETTINGS));
-
- if (tool->undo_desc)
- *undo_desc = g_strdup (tool->undo_desc);
+ *title = g_strdup (tool->title);
+ *description = g_strdup (tool->description);
+ *undo_desc = g_strdup (tool->undo_desc);
+ *icon_name = g_strdup (tool->icon_name);
+ *help_id = g_strdup (tool->help_id);
- if (tool->operation)
- return gegl_node_new_child (NULL,
- "operation", tool->operation,
- NULL);
-
- return gegl_node_new_child (NULL,
- "operation", "gegl:nop",
- NULL);
-}
-
-static void
-gimp_operation_tool_map (GimpImageMapTool *im_tool)
-{
- if (im_tool->config)
- gimp_gegl_config_sync_node (GIMP_OBJECT (im_tool->config),
- im_tool->operation);
+ return g_strdup (tool->operation);
}
static void
@@ -313,18 +304,6 @@ gimp_operation_tool_dialog (GimpImageMapTool *im_tool)
FALSE, FALSE, 0);
gtk_widget_show (tool->options_gui);
}
-
- if (tool->title)
- gimp_tool_gui_set_title (im_tool->gui, tool->title);
-
- if (tool->undo_desc)
- gimp_tool_gui_set_description (im_tool->gui, tool->undo_desc);
-
- if (tool->icon_name)
- gimp_tool_gui_set_icon_name (im_tool->gui, tool->icon_name);
-
- if (tool->help_id)
- gimp_tool_gui_set_help_id (im_tool->gui, tool->help_id);
}
static void
@@ -366,8 +345,8 @@ gimp_operation_tool_get_settings_ui (GimpImageMapTool *im_tool,
file = gimp_directory_file ("filters", basename, NULL);
g_free (basename);
- import_title = g_strdup_printf (_("Import '%s' Settings"), tool->undo_desc);
- export_title = g_strdup_printf (_("Export '%s' Settings"), tool->undo_desc);
+ import_title = g_strdup_printf (_("Import '%s' Settings"), tool->title);
+ export_title = g_strdup_printf (_("Export '%s' Settings"), tool->title);
widget =
GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->get_settings_ui (im_tool,
@@ -638,6 +617,7 @@ void
gimp_operation_tool_set_operation (GimpOperationTool *tool,
const gchar *operation,
const gchar *title,
+ const gchar *description,
const gchar *undo_desc,
const gchar *icon_name,
const gchar *help_id)
@@ -657,6 +637,9 @@ gimp_operation_tool_set_operation (GimpOperationTool *tool,
if (tool->title)
g_free (tool->title);
+ if (tool->description)
+ g_free (tool->description);
+
if (tool->undo_desc)
g_free (tool->undo_desc);
@@ -666,11 +649,12 @@ gimp_operation_tool_set_operation (GimpOperationTool *tool,
if (tool->help_id)
g_free (tool->help_id);
- tool->operation = g_strdup (operation);
- tool->title = g_strdup (title);
- tool->undo_desc = g_strdup (undo_desc);
- tool->icon_name = g_strdup (icon_name);
- tool->help_id = g_strdup (help_id);
+ tool->operation = g_strdup (operation);
+ tool->title = g_strdup (title);
+ tool->description = g_strdup (description);
+ tool->undo_desc = g_strdup (undo_desc);
+ tool->icon_name = g_strdup (icon_name);
+ tool->help_id = g_strdup (help_id);
g_list_free_full (tool->aux_inputs,
(GDestroyNotify) gimp_operation_tool_aux_input_free);
@@ -761,21 +745,6 @@ gimp_operation_tool_set_operation (GimpOperationTool *tool,
}
}
- if (im_tool->gui)
- {
- if (title)
- gimp_tool_gui_set_title (im_tool->gui, title);
-
- if (undo_desc)
- gimp_tool_gui_set_description (im_tool->gui, undo_desc);
-
- if (icon_name)
- gimp_tool_gui_set_icon_name (im_tool->gui, icon_name);
-
- if (help_id)
- gimp_tool_gui_set_help_id (im_tool->gui, help_id);
- }
-
if (GIMP_TOOL (tool)->drawable)
{
gimp_operation_tool_sync_op (tool, GIMP_TOOL (tool)->drawable);
diff --git a/app/tools/gimpoperationtool.h b/app/tools/gimpoperationtool.h
index 9e24769..b7fda95 100644
--- a/app/tools/gimpoperationtool.h
+++ b/app/tools/gimpoperationtool.h
@@ -39,6 +39,7 @@ struct _GimpOperationTool
gchar *operation;
gchar *title;
+ gchar *description;
gchar *undo_desc;
gchar *icon_name;
gchar *help_id;
@@ -64,6 +65,7 @@ GType gimp_operation_tool_get_type (void) G_GNUC_CONST;
void gimp_operation_tool_set_operation (GimpOperationTool *tool,
const gchar *operation,
const gchar *title,
+ const gchar *description,
const gchar *undo_desc,
const gchar *icon_name,
const gchar *help_id);
diff --git a/app/tools/gimpthresholdtool.c b/app/tools/gimpthresholdtool.c
index 128c23b..de54561 100644
--- a/app/tools/gimpthresholdtool.c
+++ b/app/tools/gimpthresholdtool.c
@@ -25,8 +25,6 @@
#include "tools-types.h"
-#include "operations/gimpthresholdconfig.h"
-
#include "core/gimpdrawable.h"
#include "core/gimpdrawable-histogram.h"
#include "core/gimperror.h"
@@ -47,15 +45,19 @@
/* local function prototypes */
+static void gimp_threshold_tool_constructed (GObject *object);
static void gimp_threshold_tool_finalize (GObject *object);
static gboolean gimp_threshold_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error);
-static GeglNode * gimp_threshold_tool_get_operation (GimpImageMapTool *im_tool,
- GObject **config,
- gchar **undo_desc);
+static gchar * gimp_threshold_tool_get_operation (GimpImageMapTool *im_tool,
+ gchar **title,
+ gchar **description,
+ gchar **undo_desc,
+ gchar **icon_name,
+ gchar **help_id);
static void gimp_threshold_tool_dialog (GimpImageMapTool *im_tool);
static void gimp_threshold_tool_config_notify (GObject *object,
@@ -100,11 +102,11 @@ gimp_threshold_tool_class_init (GimpThresholdToolClass *klass)
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
+ object_class->constructed = gimp_threshold_tool_constructed;
object_class->finalize = gimp_threshold_tool_finalize;
tool_class->initialize = gimp_threshold_tool_initialize;
- im_tool_class->dialog_desc = _("Apply Threshold");
im_tool_class->settings_name = "threshold";
im_tool_class->import_dialog_title = _("Import Threshold Settings");
im_tool_class->export_dialog_title = _("Export Threshold Settings");
@@ -120,6 +122,16 @@ gimp_threshold_tool_init (GimpThresholdTool *t_tool)
}
static void
+gimp_threshold_tool_constructed (GObject *object)
+{
+ G_OBJECT_CLASS (parent_class)->constructed (object);
+
+ g_signal_connect_object (GIMP_IMAGE_MAP_TOOL (object)->config, "notify",
+ G_CALLBACK (gimp_threshold_tool_config_notify),
+ object, 0);
+}
+
+static void
gimp_threshold_tool_finalize (GObject *object)
{
GimpThresholdTool *t_tool = GIMP_THRESHOLD_TOOL (object);
@@ -154,25 +166,17 @@ gimp_threshold_tool_initialize (GimpTool *tool,
return TRUE;
}
-static GeglNode *
-gimp_threshold_tool_get_operation (GimpImageMapTool *image_map_tool,
- GObject **config,
- gchar **undo_desc)
+static gchar *
+gimp_threshold_tool_get_operation (GimpImageMapTool *im_tool,
+ gchar **title,
+ gchar **description,
+ gchar **undo_desc,
+ gchar **icon_name,
+ gchar **help_id)
{
- GimpThresholdTool *t_tool = GIMP_THRESHOLD_TOOL (image_map_tool);
+ *description = g_strdup (_("Apply Threshold"));
- t_tool->config = g_object_new (GIMP_TYPE_THRESHOLD_CONFIG, NULL);
-
- g_signal_connect_object (t_tool->config, "notify",
- G_CALLBACK (gimp_threshold_tool_config_notify),
- G_OBJECT (t_tool), 0);
-
- *config = G_OBJECT (t_tool->config);
-
- return gegl_node_new_child (NULL,
- "operation", "gimp:threshold",
- "config", t_tool->config,
- NULL);
+ return g_strdup ("gimp:threshold");
}
@@ -181,19 +185,20 @@ gimp_threshold_tool_get_operation (GimpImageMapTool *image_map_tool,
/**********************/
static void
-gimp_threshold_tool_dialog (GimpImageMapTool *image_map_tool)
+gimp_threshold_tool_dialog (GimpImageMapTool *im_tool)
{
- GimpThresholdTool *t_tool = GIMP_THRESHOLD_TOOL (image_map_tool);
- GimpToolOptions *tool_options = GIMP_TOOL_GET_OPTIONS (image_map_tool);
- GimpThresholdConfig *config = t_tool->config;
- GtkWidget *main_vbox;
- GtkWidget *hbox;
- GtkWidget *menu;
- GtkWidget *box;
- GtkWidget *button;
- gint n_bins;
-
- main_vbox = gimp_image_map_tool_dialog_get_vbox (image_map_tool);
+ GimpThresholdTool *t_tool = GIMP_THRESHOLD_TOOL (im_tool);
+ GimpToolOptions *tool_options = GIMP_TOOL_GET_OPTIONS (im_tool);
+ GtkWidget *main_vbox;
+ GtkWidget *hbox;
+ GtkWidget *menu;
+ GtkWidget *box;
+ GtkWidget *button;
+ gdouble low;
+ gdouble high;
+ gint n_bins;
+
+ main_vbox = gimp_image_map_tool_dialog_get_vbox (im_tool);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
@@ -211,11 +216,16 @@ gimp_threshold_tool_dialog (GimpImageMapTool *image_map_tool)
t_tool->histogram_box = GIMP_HISTOGRAM_BOX (box);
+ g_object_get (im_tool->config,
+ "low", &low,
+ "high", &high,
+ NULL);
+
n_bins = gimp_histogram_n_bins (t_tool->histogram);
gimp_histogram_view_set_range (t_tool->histogram_box->view,
- config->low * (n_bins - 0.0001),
- config->high * (n_bins - 0.0001));
+ low * (n_bins - 0.0001),
+ high * (n_bins - 0.0001));
g_signal_connect (t_tool->histogram_box->view, "range-changed",
G_CALLBACK (gimp_threshold_tool_histogram_range),
@@ -244,17 +254,23 @@ gimp_threshold_tool_config_notify (GObject *object,
GParamSpec *pspec,
GimpThresholdTool *t_tool)
{
- GimpThresholdConfig *config = GIMP_THRESHOLD_CONFIG (object);
- gint n_bins;
+ gdouble low;
+ gdouble high;
+ gint n_bins;
if (! t_tool->histogram_box)
return;
+ g_object_get (object,
+ "low", &low,
+ "high", &high,
+ NULL);
+
n_bins = gimp_histogram_n_bins (t_tool->histogram);
gimp_histogram_view_set_range (t_tool->histogram_box->view,
- config->low * (n_bins - 0.0001),
- config->high * (n_bins - 0.0001));
+ low * (n_bins - 0.0001),
+ high * (n_bins - 0.0001));
}
static void
@@ -263,14 +279,22 @@ gimp_threshold_tool_histogram_range (GimpHistogramView *widget,
gint end,
GimpThresholdTool *t_tool)
{
- gint n_bins = gimp_histogram_n_bins (t_tool->histogram);
- gdouble low = (gdouble) start / (n_bins - 1);
- gdouble high = (gdouble) end / (n_bins - 1);
-
- if (low != t_tool->config->low ||
- high != t_tool->config->high)
+ GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (t_tool);
+ gint n_bins = gimp_histogram_n_bins (t_tool->histogram);
+ gdouble low = (gdouble) start / (n_bins - 1);
+ gdouble high = (gdouble) end / (n_bins - 1);
+ gdouble config_low;
+ gdouble config_high;
+
+ g_object_get (im_tool->config,
+ "low", &config_low,
+ "high", &config_high,
+ NULL);
+
+ if (low != config_low ||
+ high != config_high)
{
- g_object_set (t_tool->config,
+ g_object_set (im_tool->config,
"low", low,
"high", high,
NULL);
diff --git a/app/tools/gimpthresholdtool.h b/app/tools/gimpthresholdtool.h
index d6c284a..3915836 100644
--- a/app/tools/gimpthresholdtool.h
+++ b/app/tools/gimpthresholdtool.h
@@ -35,13 +35,11 @@ typedef struct _GimpThresholdToolClass GimpThresholdToolClass;
struct _GimpThresholdTool
{
- GimpImageMapTool parent_instance;
-
- GimpThresholdConfig *config;
+ GimpImageMapTool parent_instance;
/* dialog */
- GimpHistogram *histogram;
- GimpHistogramBox *histogram_box;
+ GimpHistogram *histogram;
+ GimpHistogramBox *histogram_box;
};
struct _GimpThresholdToolClass
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]