app: add a default impl of GimpImageMapTool::reset()

and chain up where possible instead of duplicating that code.
This commit is contained in:
Michael Natterer 2014-05-16 16:22:31 +02:00
parent 86988e7d67
commit f50b215d16
3 changed files with 30 additions and 46 deletions

View File

@ -250,24 +250,11 @@ gimp_color_balance_tool_reset (GimpImageMapTool *im_tool)
GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (im_tool);
GimpTransferMode range = cb_tool->config->range;
g_object_freeze_notify (im_tool->config);
if (im_tool->default_config)
{
gimp_config_copy (GIMP_CONFIG (im_tool->default_config),
GIMP_CONFIG (im_tool->config),
0);
}
else
{
gimp_config_reset (GIMP_CONFIG (im_tool->config));
}
GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->reset (im_tool);
g_object_set (cb_tool->config,
"range", range,
NULL);
g_object_thaw_notify (im_tool->config);
}
static void

View File

@ -104,6 +104,8 @@ static void gimp_image_map_tool_color_picked (GimpColorTool *color_too
const GimpRGB *color,
gint color_index);
static void gimp_image_map_tool_real_reset (GimpImageMapTool *im_tool);
static void gimp_image_map_tool_halt (GimpImageMapTool *im_tool);
static void gimp_image_map_tool_commit (GimpImageMapTool *im_tool);
@ -185,7 +187,7 @@ gimp_image_map_tool_class_init (GimpImageMapToolClass *klass)
klass->get_operation = NULL;
klass->map = NULL;
klass->dialog = NULL;
klass->reset = NULL;
klass->reset = gimp_image_map_tool_real_reset;
klass->get_settings_ui = gimp_image_map_tool_real_get_settings_ui;
klass->settings_import = gimp_image_map_tool_real_settings_import;
klass->settings_export = gimp_image_map_tool_real_settings_export;
@ -574,6 +576,24 @@ gimp_image_map_tool_color_picked (GimpColorTool *color_tool,
color);
}
static void
gimp_image_map_tool_real_reset (GimpImageMapTool *im_tool)
{
if (im_tool->config)
{
if (im_tool->default_config)
{
gimp_config_copy (GIMP_CONFIG (im_tool->default_config),
GIMP_CONFIG (im_tool->config),
0);
}
else
{
gimp_config_reset (GIMP_CONFIG (im_tool->config));
}
}
}
static void
gimp_image_map_tool_halt (GimpImageMapTool *im_tool)
{
@ -666,23 +686,13 @@ gimp_image_map_tool_dialog_unmap (GtkWidget *dialog,
static void
gimp_image_map_tool_reset (GimpImageMapTool *tool)
{
if (GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->reset)
{
GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->reset (tool);
}
else if (tool->config)
{
if (tool->default_config)
{
gimp_config_copy (GIMP_CONFIG (tool->default_config),
GIMP_CONFIG (tool->config),
0);
}
else
{
gimp_config_reset (GIMP_CONFIG (tool->config));
}
}
if (tool->config)
g_object_freeze_notify (tool->config);
GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->reset (tool);
if (tool->config)
g_object_thaw_notify (tool->config);
}
static void

View File

@ -605,24 +605,11 @@ gimp_levels_tool_reset (GimpImageMapTool *image_map_tool)
GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool);
GimpHistogramChannel channel = tool->config->channel;
g_object_freeze_notify (image_map_tool->config);
if (image_map_tool->default_config)
{
gimp_config_copy (GIMP_CONFIG (image_map_tool->default_config),
GIMP_CONFIG (image_map_tool->config),
0);
}
else
{
gimp_config_reset (GIMP_CONFIG (image_map_tool->config));
}
GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->reset (image_map_tool);
g_object_set (tool->config,
"channel", channel,
NULL);
g_object_thaw_notify (image_map_tool->config);
}
static gboolean