mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-04 17:59:37 +00:00
app: add GimpOperationSettings
Add a new GimpOperationSettings class, to be used as a base class for all operation-config types. The class provides options common to all operations (namely, the clipping mode, input region, and color options), which were previously stored in GimpFilterOptions, and were therefore bound to the filter tool, instead of being stored as part of the operation settings; as a result, these options would have no effect when reapplying a filter, or when restoring a preset. The GimpOperationSettings options do not affect the operation node, but rather the associated GimpDrawableFilter object. The class provides a gimp_operation_settings_sync_drawable_filter() function, which applies the options to the filter. Modify all custom and auto-generated operation-config types to derive from GimpOperationSettings, and modify the GimpConfig functions of the former to account for the GimpOperationSettings properties, using a set of protected functions provided by the class.
This commit is contained in:
parent
8c619bf0b2
commit
a1ff1601ee
20 changed files with 435 additions and 71 deletions
|
@ -29,12 +29,12 @@
|
|||
#include "actions-types.h"
|
||||
|
||||
#include "operations/gimp-operation-config.h"
|
||||
#include "operations/gimpoperationsettings.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimp-filter-history.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpprogress.h"
|
||||
#include "core/gimpsettings.h"
|
||||
|
||||
#include "widgets/gimpaction.h"
|
||||
|
||||
|
@ -193,7 +193,7 @@ filters_parse_operation (Gimp *gimp,
|
|||
*settings =
|
||||
g_object_new (gimp_operation_config_get_type (gimp, operation,
|
||||
icon_name,
|
||||
GIMP_TYPE_SETTINGS),
|
||||
GIMP_TYPE_OPERATION_SETTINGS),
|
||||
NULL);
|
||||
|
||||
if (! gimp_config_deserialize_string (GIMP_CONFIG (*settings),
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "config/gimpguiconfig.h"
|
||||
|
||||
#include "operations/gimp-operation-config.h"
|
||||
#include "operations/gimpoperationsettings.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimp-memsize.h"
|
||||
|
@ -387,7 +388,7 @@ gimp_gegl_procedure_new (Gimp *gimp,
|
|||
g_return_val_if_fail (menu_label != NULL, NULL);
|
||||
|
||||
config_type = gimp_operation_config_get_type (gimp, operation, icon_name,
|
||||
GIMP_TYPE_SETTINGS);
|
||||
GIMP_TYPE_OPERATION_SETTINGS);
|
||||
|
||||
procedure = g_object_new (GIMP_TYPE_GEGL_PROCEDURE, NULL);
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@ libappoperations_a_sources = \
|
|||
\
|
||||
gimp-operation-config.c \
|
||||
gimp-operation-config.h \
|
||||
gimpoperationsettings.c \
|
||||
gimpoperationsettings.h \
|
||||
gimpbrightnesscontrastconfig.c \
|
||||
gimpbrightnesscontrastconfig.h \
|
||||
gimpcageconfig.c \
|
||||
|
|
|
@ -59,7 +59,7 @@ static gboolean gimp_brightness_contrast_config_equal (GimpConfig *a,
|
|||
|
||||
G_DEFINE_TYPE_WITH_CODE (GimpBrightnessContrastConfig,
|
||||
gimp_brightness_contrast_config,
|
||||
GIMP_TYPE_SETTINGS,
|
||||
GIMP_TYPE_OPERATION_SETTINGS,
|
||||
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG,
|
||||
gimp_brightness_contrast_config_iface_init))
|
||||
|
||||
|
@ -156,7 +156,8 @@ gimp_brightness_contrast_config_equal (GimpConfig *a,
|
|||
GimpBrightnessContrastConfig *config_a = GIMP_BRIGHTNESS_CONTRAST_CONFIG (a);
|
||||
GimpBrightnessContrastConfig *config_b = GIMP_BRIGHTNESS_CONTRAST_CONFIG (b);
|
||||
|
||||
if (config_a->brightness != config_b->brightness ||
|
||||
if (! gimp_operation_settings_config_equal_base (a, b) ||
|
||||
config_a->brightness != config_b->brightness ||
|
||||
config_a->contrast != config_b->contrast)
|
||||
{
|
||||
return FALSE;
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#define __GIMP_BRIGHTNESS_CONTRAST_CONFIG_H__
|
||||
|
||||
|
||||
#include "core/gimpsettings.h"
|
||||
#include "gimpoperationsettings.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG (gimp_brightness_contrast_config_get_type ())
|
||||
|
@ -37,15 +37,15 @@ typedef struct _GimpBrightnessContrastConfigClass GimpBrightnessContrastConfigCl
|
|||
|
||||
struct _GimpBrightnessContrastConfig
|
||||
{
|
||||
GimpSettings parent_instance;
|
||||
GimpOperationSettings parent_instance;
|
||||
|
||||
gdouble brightness;
|
||||
gdouble contrast;
|
||||
gdouble brightness;
|
||||
gdouble contrast;
|
||||
};
|
||||
|
||||
struct _GimpBrightnessContrastConfigClass
|
||||
{
|
||||
GimpSettingsClass parent_class;
|
||||
GimpOperationSettingsClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ static void gimp_cage_config_compute_edges_normal (GimpCageConfig *gcc);
|
|||
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GimpCageConfig, gimp_cage_config,
|
||||
GIMP_TYPE_SETTINGS,
|
||||
GIMP_TYPE_OPERATION_SETTINGS,
|
||||
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG,
|
||||
NULL))
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#define __GIMP_CAGE_CONFIG_H__
|
||||
|
||||
|
||||
#include "core/gimpsettings.h"
|
||||
#include "gimpoperationsettings.h"
|
||||
|
||||
|
||||
struct _GimpCagePoint
|
||||
|
@ -46,18 +46,18 @@ typedef struct _GimpCageConfigClass GimpCageConfigClass;
|
|||
|
||||
struct _GimpCageConfig
|
||||
{
|
||||
GimpSettings parent_instance;
|
||||
GimpOperationSettings parent_instance;
|
||||
|
||||
GArray *cage_points;
|
||||
GArray *cage_points;
|
||||
|
||||
gdouble displacement_x;
|
||||
gdouble displacement_y;
|
||||
GimpCageMode cage_mode; /* Cage mode, used to commit displacement */
|
||||
gdouble displacement_x;
|
||||
gdouble displacement_y;
|
||||
GimpCageMode cage_mode; /* Cage mode, used to commit displacement */
|
||||
};
|
||||
|
||||
struct _GimpCageConfigClass
|
||||
{
|
||||
GimpSettingsClass parent_class;
|
||||
GimpOperationSettingsClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ static gboolean gimp_color_balance_config_copy (GimpConfig *src,
|
|||
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GimpColorBalanceConfig, gimp_color_balance_config,
|
||||
GIMP_TYPE_SETTINGS,
|
||||
GIMP_TYPE_OPERATION_SETTINGS,
|
||||
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG,
|
||||
gimp_color_balance_config_iface_init))
|
||||
|
||||
|
@ -224,7 +224,7 @@ gimp_color_balance_config_serialize (GimpConfig *config,
|
|||
GimpTransferMode old_range;
|
||||
gboolean success = TRUE;
|
||||
|
||||
if (! gimp_config_serialize_property_by_name (config, "time", writer))
|
||||
if (! gimp_operation_settings_config_serialize_base (config, writer, data))
|
||||
return FALSE;
|
||||
|
||||
old_range = bc_config->range;
|
||||
|
@ -289,6 +289,9 @@ gimp_color_balance_config_equal (GimpConfig *a,
|
|||
GimpColorBalanceConfig *config_b = GIMP_COLOR_BALANCE_CONFIG (b);
|
||||
GimpTransferMode range;
|
||||
|
||||
if (! gimp_operation_settings_config_equal_base (a, b))
|
||||
return FALSE;
|
||||
|
||||
for (range = GIMP_TRANSFER_SHADOWS;
|
||||
range <= GIMP_TRANSFER_HIGHLIGHTS;
|
||||
range++)
|
||||
|
@ -313,6 +316,8 @@ gimp_color_balance_config_reset (GimpConfig *config)
|
|||
GimpColorBalanceConfig *cb_config = GIMP_COLOR_BALANCE_CONFIG (config);
|
||||
GimpTransferMode range;
|
||||
|
||||
gimp_operation_settings_config_reset_base (config);
|
||||
|
||||
for (range = GIMP_TRANSFER_SHADOWS;
|
||||
range <= GIMP_TRANSFER_HIGHLIGHTS;
|
||||
range++)
|
||||
|
@ -334,6 +339,9 @@ gimp_color_balance_config_copy (GimpConfig *src,
|
|||
GimpColorBalanceConfig *dest_config = GIMP_COLOR_BALANCE_CONFIG (dest);
|
||||
GimpTransferMode range;
|
||||
|
||||
if (! gimp_operation_settings_config_copy_base (src, dest, flags))
|
||||
return FALSE;
|
||||
|
||||
for (range = GIMP_TRANSFER_SHADOWS;
|
||||
range <= GIMP_TRANSFER_HIGHLIGHTS;
|
||||
range++)
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#define __GIMP_COLOR_BALANCE_CONFIG_H__
|
||||
|
||||
|
||||
#include "core/gimpsettings.h"
|
||||
#include "gimpoperationsettings.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_COLOR_BALANCE_CONFIG (gimp_color_balance_config_get_type ())
|
||||
|
@ -37,20 +37,20 @@ typedef struct _GimpColorBalanceConfigClass GimpColorBalanceConfigClass;
|
|||
|
||||
struct _GimpColorBalanceConfig
|
||||
{
|
||||
GimpSettings parent_instance;
|
||||
GimpOperationSettings parent_instance;
|
||||
|
||||
GimpTransferMode range;
|
||||
GimpTransferMode range;
|
||||
|
||||
gdouble cyan_red[3];
|
||||
gdouble magenta_green[3];
|
||||
gdouble yellow_blue[3];
|
||||
gdouble cyan_red[3];
|
||||
gdouble magenta_green[3];
|
||||
gdouble yellow_blue[3];
|
||||
|
||||
gboolean preserve_luminosity;
|
||||
gboolean preserve_luminosity;
|
||||
};
|
||||
|
||||
struct _GimpColorBalanceConfigClass
|
||||
{
|
||||
GimpSettingsClass parent_class;
|
||||
GimpOperationSettingsClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ static void gimp_curves_config_curve_dirty (GimpCurve *curve,
|
|||
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GimpCurvesConfig, gimp_curves_config,
|
||||
GIMP_TYPE_SETTINGS,
|
||||
GIMP_TYPE_OPERATION_SETTINGS,
|
||||
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG,
|
||||
gimp_curves_config_iface_init))
|
||||
|
||||
|
@ -261,8 +261,8 @@ gimp_curves_config_serialize (GimpConfig *config,
|
|||
GimpHistogramChannel old_channel;
|
||||
gboolean success = TRUE;
|
||||
|
||||
if (! gimp_config_serialize_property_by_name (config, "time", writer) ||
|
||||
! gimp_config_serialize_property_by_name (config, "trc", writer))
|
||||
if (! gimp_operation_settings_config_serialize_base (config, writer, data) ||
|
||||
! gimp_config_serialize_property_by_name (config, "trc", writer))
|
||||
return FALSE;
|
||||
|
||||
old_channel = c_config->channel;
|
||||
|
@ -273,10 +273,10 @@ gimp_curves_config_serialize (GimpConfig *config,
|
|||
{
|
||||
c_config->channel = channel;
|
||||
|
||||
/* Serialize the channel properties manually (not using
|
||||
/* serialize the channel properties manually (not using
|
||||
* gimp_config_serialize_properties()), so the parent class'
|
||||
* "time" property doesn't end up in the config file once per
|
||||
* channel. See bug #700653.
|
||||
* properties don't end up in the config file one per channel.
|
||||
* See bug #700653.
|
||||
*/
|
||||
success =
|
||||
(gimp_config_serialize_property_by_name (config, "channel", writer) &&
|
||||
|
@ -318,7 +318,8 @@ gimp_curves_config_equal (GimpConfig *a,
|
|||
GimpCurvesConfig *config_b = GIMP_CURVES_CONFIG (b);
|
||||
GimpHistogramChannel channel;
|
||||
|
||||
if (config_a->trc != config_b->trc)
|
||||
if (! gimp_operation_settings_config_equal_base (a, b) ||
|
||||
config_a->trc != config_b->trc)
|
||||
return FALSE;
|
||||
|
||||
for (channel = GIMP_HISTOGRAM_VALUE;
|
||||
|
@ -351,6 +352,8 @@ gimp_curves_config_reset (GimpConfig *config)
|
|||
GimpCurvesConfig *c_config = GIMP_CURVES_CONFIG (config);
|
||||
GimpHistogramChannel channel;
|
||||
|
||||
gimp_operation_settings_config_reset_base (config);
|
||||
|
||||
for (channel = GIMP_HISTOGRAM_VALUE;
|
||||
channel <= GIMP_HISTOGRAM_ALPHA;
|
||||
channel++)
|
||||
|
@ -372,6 +375,9 @@ gimp_curves_config_copy (GimpConfig *src,
|
|||
GimpCurvesConfig *dest_config = GIMP_CURVES_CONFIG (dest);
|
||||
GimpHistogramChannel channel;
|
||||
|
||||
if (! gimp_operation_settings_config_copy_base (src, dest, flags))
|
||||
return FALSE;
|
||||
|
||||
for (channel = GIMP_HISTOGRAM_VALUE;
|
||||
channel <= GIMP_HISTOGRAM_ALPHA;
|
||||
channel++)
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#define __GIMP_CURVES_CONFIG_H__
|
||||
|
||||
|
||||
#include "core/gimpsettings.h"
|
||||
#include "gimpoperationsettings.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_CURVES_CONFIG (gimp_curves_config_get_type ())
|
||||
|
@ -37,18 +37,18 @@ typedef struct _GimpCurvesConfigClass GimpCurvesConfigClass;
|
|||
|
||||
struct _GimpCurvesConfig
|
||||
{
|
||||
GimpSettings parent_instance;
|
||||
GimpOperationSettings parent_instance;
|
||||
|
||||
GimpTRCType trc;
|
||||
GimpTRCType trc;
|
||||
|
||||
GimpHistogramChannel channel;
|
||||
GimpHistogramChannel channel;
|
||||
|
||||
GimpCurve *curve[5];
|
||||
GimpCurve *curve[5];
|
||||
};
|
||||
|
||||
struct _GimpCurvesConfigClass
|
||||
{
|
||||
GimpSettingsClass parent_class;
|
||||
GimpOperationSettingsClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ static gboolean gimp_hue_saturation_config_copy (GimpConfig *src,
|
|||
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GimpHueSaturationConfig, gimp_hue_saturation_config,
|
||||
GIMP_TYPE_SETTINGS,
|
||||
GIMP_TYPE_OPERATION_SETTINGS,
|
||||
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG,
|
||||
gimp_hue_saturation_config_iface_init))
|
||||
|
||||
|
@ -222,7 +222,7 @@ gimp_hue_saturation_config_serialize (GimpConfig *config,
|
|||
GimpHueRange old_range;
|
||||
gboolean success = TRUE;
|
||||
|
||||
if (! gimp_config_serialize_property_by_name (config, "time", writer))
|
||||
if (! gimp_operation_settings_config_serialize_base (config, writer, data))
|
||||
return FALSE;
|
||||
|
||||
old_range = hs_config->range;
|
||||
|
@ -280,6 +280,9 @@ gimp_hue_saturation_config_equal (GimpConfig *a,
|
|||
GimpHueSaturationConfig *config_b = GIMP_HUE_SATURATION_CONFIG (b);
|
||||
GimpHueRange range;
|
||||
|
||||
if (! gimp_operation_settings_config_equal_base (a, b))
|
||||
return FALSE;
|
||||
|
||||
for (range = GIMP_HUE_RANGE_ALL; range <= GIMP_HUE_RANGE_MAGENTA; range++)
|
||||
{
|
||||
if (config_a->hue[range] != config_b->hue[range] ||
|
||||
|
@ -302,6 +305,8 @@ gimp_hue_saturation_config_reset (GimpConfig *config)
|
|||
GimpHueSaturationConfig *hs_config = GIMP_HUE_SATURATION_CONFIG (config);
|
||||
GimpHueRange range;
|
||||
|
||||
gimp_operation_settings_config_reset_base (config);
|
||||
|
||||
for (range = GIMP_HUE_RANGE_ALL; range <= GIMP_HUE_RANGE_MAGENTA; range++)
|
||||
{
|
||||
hs_config->range = range;
|
||||
|
@ -321,6 +326,9 @@ gimp_hue_saturation_config_copy (GimpConfig *src,
|
|||
GimpHueSaturationConfig *dest_config = GIMP_HUE_SATURATION_CONFIG (dest);
|
||||
GimpHueRange range;
|
||||
|
||||
if (! gimp_operation_settings_config_copy_base (src, dest, flags))
|
||||
return FALSE;
|
||||
|
||||
for (range = GIMP_HUE_RANGE_ALL; range <= GIMP_HUE_RANGE_MAGENTA; range++)
|
||||
{
|
||||
dest_config->hue[range] = src_config->hue[range];
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#define __GIMP_HUE_SATURATION_CONFIG_H__
|
||||
|
||||
|
||||
#include "core/gimpsettings.h"
|
||||
#include "gimpoperationsettings.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_HUE_SATURATION_CONFIG (gimp_hue_saturation_config_get_type ())
|
||||
|
@ -37,20 +37,20 @@ typedef struct _GimpHueSaturationConfigClass GimpHueSaturationConfigClass;
|
|||
|
||||
struct _GimpHueSaturationConfig
|
||||
{
|
||||
GimpSettings parent_instance;
|
||||
GimpOperationSettings parent_instance;
|
||||
|
||||
GimpHueRange range;
|
||||
GimpHueRange range;
|
||||
|
||||
gdouble hue[7];
|
||||
gdouble saturation[7];
|
||||
gdouble lightness[7];
|
||||
gdouble hue[7];
|
||||
gdouble saturation[7];
|
||||
gdouble lightness[7];
|
||||
|
||||
gdouble overlap;
|
||||
gdouble overlap;
|
||||
};
|
||||
|
||||
struct _GimpHueSaturationConfigClass
|
||||
{
|
||||
GimpSettingsClass parent_class;
|
||||
GimpOperationSettingsClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ static gboolean gimp_levels_config_copy (GimpConfig *src,
|
|||
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GimpLevelsConfig, gimp_levels_config,
|
||||
GIMP_TYPE_SETTINGS,
|
||||
GIMP_TYPE_OPERATION_SETTINGS,
|
||||
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG,
|
||||
gimp_levels_config_iface_init))
|
||||
|
||||
|
@ -314,8 +314,8 @@ gimp_levels_config_serialize (GimpConfig *config,
|
|||
GimpHistogramChannel old_channel;
|
||||
gboolean success = TRUE;
|
||||
|
||||
if (! gimp_config_serialize_property_by_name (config, "time", writer) ||
|
||||
! gimp_config_serialize_property_by_name (config, "trc", writer) ||
|
||||
if (! gimp_operation_settings_config_serialize_base (config, writer, data) ||
|
||||
! gimp_config_serialize_property_by_name (config, "trc", writer) ||
|
||||
! gimp_config_serialize_property_by_name (config, "clamp-input", writer) ||
|
||||
! gimp_config_serialize_property_by_name (config, "clamp-output", writer))
|
||||
return FALSE;
|
||||
|
@ -330,8 +330,8 @@ gimp_levels_config_serialize (GimpConfig *config,
|
|||
|
||||
/* serialize the channel properties manually (not using
|
||||
* gimp_config_serialize_properties()), so the parent class'
|
||||
* "time" property doesn't end up in the config file one per
|
||||
* channel. See bug #700653.
|
||||
* properties don't end up in the config file one per channel.
|
||||
* See bug #700653.
|
||||
*/
|
||||
success =
|
||||
(gimp_config_serialize_property_by_name (config, "channel", writer) &&
|
||||
|
@ -377,8 +377,9 @@ gimp_levels_config_equal (GimpConfig *a,
|
|||
GimpLevelsConfig *config_b = GIMP_LEVELS_CONFIG (b);
|
||||
GimpHistogramChannel channel;
|
||||
|
||||
if (config_a->trc != config_b->trc ||
|
||||
config_a->clamp_input != config_b->clamp_input ||
|
||||
if (! gimp_operation_settings_config_equal_base (a, b) ||
|
||||
config_a->trc != config_b->trc ||
|
||||
config_a->clamp_input != config_b->clamp_input ||
|
||||
config_a->clamp_output != config_b->clamp_output)
|
||||
return FALSE;
|
||||
|
||||
|
@ -405,6 +406,8 @@ gimp_levels_config_reset (GimpConfig *config)
|
|||
GimpLevelsConfig *l_config = GIMP_LEVELS_CONFIG (config);
|
||||
GimpHistogramChannel channel;
|
||||
|
||||
gimp_operation_settings_config_reset_base (config);
|
||||
|
||||
for (channel = GIMP_HISTOGRAM_VALUE;
|
||||
channel <= GIMP_HISTOGRAM_ALPHA;
|
||||
channel++)
|
||||
|
@ -428,6 +431,9 @@ gimp_levels_config_copy (GimpConfig *src,
|
|||
GimpLevelsConfig *dest_config = GIMP_LEVELS_CONFIG (dest);
|
||||
GimpHistogramChannel channel;
|
||||
|
||||
if (! gimp_operation_settings_config_copy_base (src, dest, flags))
|
||||
return FALSE;
|
||||
|
||||
for (channel = GIMP_HISTOGRAM_VALUE;
|
||||
channel <= GIMP_HISTOGRAM_ALPHA;
|
||||
channel++)
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#define __GIMP_LEVELS_CONFIG_H__
|
||||
|
||||
|
||||
#include "core/gimpsettings.h"
|
||||
#include "gimpoperationsettings.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_LEVELS_CONFIG (gimp_levels_config_get_type ())
|
||||
|
@ -37,28 +37,28 @@ typedef struct _GimpLevelsConfigClass GimpLevelsConfigClass;
|
|||
|
||||
struct _GimpLevelsConfig
|
||||
{
|
||||
GimpSettings parent_instance;
|
||||
GimpOperationSettings parent_instance;
|
||||
|
||||
GimpTRCType trc;
|
||||
GimpTRCType trc;
|
||||
|
||||
GimpHistogramChannel channel;
|
||||
GimpHistogramChannel channel;
|
||||
|
||||
gdouble low_input[5];
|
||||
gdouble high_input[5];
|
||||
gdouble low_input[5];
|
||||
gdouble high_input[5];
|
||||
|
||||
gboolean clamp_input;
|
||||
gboolean clamp_input;
|
||||
|
||||
gdouble gamma[5];
|
||||
gdouble gamma[5];
|
||||
|
||||
gdouble low_output[5];
|
||||
gdouble high_output[5];
|
||||
gdouble low_output[5];
|
||||
gdouble high_output[5];
|
||||
|
||||
gboolean clamp_output;
|
||||
gboolean clamp_output;
|
||||
};
|
||||
|
||||
struct _GimpLevelsConfigClass
|
||||
{
|
||||
GimpSettingsClass parent_class;
|
||||
GimpOperationSettingsClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
|
|
256
app/operations/gimpoperationsettings.c
Normal file
256
app/operations/gimpoperationsettings.c
Normal file
|
@ -0,0 +1,256 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpoperationsettings.c
|
||||
* Copyright (C) 2020 Ell
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <gegl.h>
|
||||
|
||||
#include "libgimpconfig/gimpconfig.h"
|
||||
|
||||
#include "operations-types.h"
|
||||
|
||||
#include "gegl/gimp-gegl-utils.h"
|
||||
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpdrawablefilter.h"
|
||||
|
||||
#include "gimpoperationsettings.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_CLIP,
|
||||
PROP_REGION,
|
||||
PROP_GAMMA_HACK
|
||||
};
|
||||
|
||||
|
||||
static void gimp_operation_settings_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_operation_settings_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpOperationSettings, gimp_operation_settings,
|
||||
GIMP_TYPE_SETTINGS)
|
||||
|
||||
#define parent_class gimp_operation_settings_parent_class
|
||||
|
||||
|
||||
static void
|
||||
gimp_operation_settings_class_init (GimpOperationSettingsClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->set_property = gimp_operation_settings_set_property;
|
||||
object_class->get_property = gimp_operation_settings_get_property;
|
||||
|
||||
GIMP_CONFIG_PROP_ENUM (object_class, PROP_CLIP,
|
||||
"gimp-clip",
|
||||
_("Clipping"),
|
||||
_("How to clip"),
|
||||
GIMP_TYPE_TRANSFORM_RESIZE,
|
||||
GIMP_TRANSFORM_RESIZE_ADJUST,
|
||||
GIMP_CONFIG_PARAM_DEFAULTS);
|
||||
|
||||
GIMP_CONFIG_PROP_ENUM (object_class, PROP_REGION,
|
||||
"gimp-region",
|
||||
NULL, NULL,
|
||||
GIMP_TYPE_FILTER_REGION,
|
||||
GIMP_FILTER_REGION_SELECTION,
|
||||
GIMP_CONFIG_PARAM_DEFAULTS);
|
||||
|
||||
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_GAMMA_HACK,
|
||||
"gimp-gamma-hack",
|
||||
"Gamma hack (temp hack, please ignore)",
|
||||
NULL,
|
||||
FALSE,
|
||||
GIMP_CONFIG_PARAM_DEFAULTS);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_operation_settings_init (GimpOperationSettings *settings)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_operation_settings_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpOperationSettings *settings = GIMP_OPERATION_SETTINGS (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_CLIP:
|
||||
g_value_set_enum (value, settings->clip);
|
||||
break;
|
||||
|
||||
case PROP_REGION:
|
||||
g_value_set_enum (value, settings->region);
|
||||
break;
|
||||
|
||||
case PROP_GAMMA_HACK:
|
||||
g_value_set_boolean (value, settings->gamma_hack);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_operation_settings_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpOperationSettings *settings = GIMP_OPERATION_SETTINGS (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_CLIP:
|
||||
settings->clip = g_value_get_enum (value);
|
||||
break;
|
||||
|
||||
case PROP_REGION:
|
||||
settings->region = g_value_get_enum (value);
|
||||
break;
|
||||
|
||||
case PROP_COLOR_MANAGED:
|
||||
settings->color_managed = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
case PROP_GAMMA_HACK:
|
||||
settings->gamma_hack = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
void
|
||||
gimp_operation_settings_sync_drawable_filter (GimpOperationSettings *settings,
|
||||
GimpDrawableFilter *filter)
|
||||
{
|
||||
gboolean clip;
|
||||
|
||||
g_return_if_fail (GIMP_IS_OPERATION_SETTINGS (settings));
|
||||
g_return_if_fail (GIMP_IS_DRAWABLE_FILTER (filter));
|
||||
|
||||
clip = settings->clip == GIMP_TRANSFORM_RESIZE_CLIP ||
|
||||
! babl_format_has_alpha (gimp_drawable_filter_get_format (filter));
|
||||
|
||||
gimp_drawable_filter_set_region (filter, settings->region);
|
||||
gimp_drawable_filter_set_clip (filter, clip);
|
||||
gimp_drawable_filter_set_gamma_hack (filter, settings->gamma_hack);
|
||||
}
|
||||
|
||||
|
||||
/* protected functions */
|
||||
|
||||
static const gchar * const base_properties[] =
|
||||
{
|
||||
"time",
|
||||
"gimp-clip",
|
||||
"gimp-region",
|
||||
"gimp-gamma-hack"
|
||||
};
|
||||
|
||||
gboolean
|
||||
gimp_operation_settings_config_serialize_base (GimpConfig *config,
|
||||
GimpConfigWriter *writer,
|
||||
gpointer data)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (base_properties); i++)
|
||||
{
|
||||
if (! gimp_config_serialize_property_by_name (config,
|
||||
base_properties[i],
|
||||
writer))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_settings_config_equal_base (GimpConfig *a,
|
||||
GimpConfig *b)
|
||||
{
|
||||
GimpOperationSettings *settings_a = GIMP_OPERATION_SETTINGS (a);
|
||||
GimpOperationSettings *settings_b = GIMP_OPERATION_SETTINGS (b);
|
||||
|
||||
return settings_a->clip == settings_b->clip &&
|
||||
settings_a->region == settings_b->region &&
|
||||
settings_a->gamma_hack == settings_b->gamma_hack;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_operation_settings_config_reset_base (GimpConfig *config)
|
||||
{
|
||||
gint i;
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (config));
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (base_properties); i++)
|
||||
gimp_config_reset_property (G_OBJECT (config), base_properties[i]);
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (config));
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_settings_config_copy_base (GimpConfig *src,
|
||||
GimpConfig *dest,
|
||||
GParamFlags flags)
|
||||
{
|
||||
gint i;
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (dest));
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (base_properties); i++)
|
||||
{
|
||||
g_object_unref (g_object_bind_property (src, base_properties[i],
|
||||
dest, base_properties[i],
|
||||
G_BINDING_SYNC_CREATE));
|
||||
}
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (dest));
|
||||
|
||||
return TRUE;
|
||||
}
|
72
app/operations/gimpoperationsettings.h
Normal file
72
app/operations/gimpoperationsettings.h
Normal file
|
@ -0,0 +1,72 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpoperationsettings.h
|
||||
* Copyright (C) 2020 Ell
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_OPERATION_SETTINGS_H__
|
||||
#define __GIMP_OPERATION_SETTINGS_H__
|
||||
|
||||
|
||||
#include "core/gimpsettings.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_OPERATION_SETTINGS (gimp_operation_settings_get_type ())
|
||||
#define GIMP_OPERATION_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_OPERATION_SETTINGS, GimpOperationSettings))
|
||||
#define GIMP_OPERATION_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_OPERATION_SETTINGS, GimpOperationSettingsClass))
|
||||
#define GIMP_IS_OPERATION_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_OPERATION_SETTINGS))
|
||||
#define GIMP_IS_OPERATION_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_OPERATION_SETTINGS))
|
||||
#define GIMP_OPERATION_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_OPERATION_SETTINGS, GimpOperationSettingsClass))
|
||||
|
||||
|
||||
typedef struct _GimpOperationSettingsClass GimpOperationSettingsClass;
|
||||
|
||||
struct _GimpOperationSettings
|
||||
{
|
||||
GimpSettings parent_instance;
|
||||
|
||||
GimpTransformResize clip;
|
||||
GimpFilterRegion region;
|
||||
gboolean gamma_hack;
|
||||
};
|
||||
|
||||
struct _GimpOperationSettingsClass
|
||||
{
|
||||
GimpSettingsClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_operation_settings_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void gimp_operation_settings_sync_drawable_filter (GimpOperationSettings *settings,
|
||||
GimpDrawableFilter *filter);
|
||||
|
||||
|
||||
/* protected */
|
||||
|
||||
gboolean gimp_operation_settings_config_serialize_base (GimpConfig *config,
|
||||
GimpConfigWriter *writer,
|
||||
gpointer data);
|
||||
gboolean gimp_operation_settings_config_equal_base (GimpConfig *a,
|
||||
GimpConfig *b);
|
||||
void gimp_operation_settings_config_reset_base (GimpConfig *config);
|
||||
gboolean gimp_operation_settings_config_copy_base (GimpConfig *src,
|
||||
GimpConfig *dest,
|
||||
GParamFlags flags);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_SETTINGS_H__ */
|
|
@ -36,6 +36,8 @@ typedef struct _GimpOperationLayerMode GimpOperationLayerMode;
|
|||
|
||||
/* operation config objects */
|
||||
|
||||
typedef struct _GimpOperationSettings GimpOperationSettings;
|
||||
|
||||
typedef struct _GimpBrightnessContrastConfig GimpBrightnessContrastConfig;
|
||||
typedef struct _GimpCageConfig GimpCageConfig;
|
||||
typedef struct _GimpColorBalanceConfig GimpColorBalanceConfig;
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "config/gimpguiconfig.h"
|
||||
|
||||
#include "operations/gimp-operation-config.h"
|
||||
#include "operations/gimpoperationsettings.h"
|
||||
|
||||
#include "gegl/gimp-gegl-utils.h"
|
||||
|
||||
|
@ -1526,7 +1527,7 @@ gimp_filter_tool_get_operation (GimpFilterTool *filter_tool)
|
|||
g_object_new (gimp_operation_config_get_type (tool->tool_info->gimp,
|
||||
operation_name,
|
||||
gimp_tool_get_icon_name (tool),
|
||||
GIMP_TYPE_SETTINGS),
|
||||
GIMP_TYPE_OPERATION_SETTINGS),
|
||||
NULL);
|
||||
|
||||
gimp_operation_config_sync_node (filter_tool->config,
|
||||
|
|
|
@ -306,6 +306,7 @@ app/operations/gimpoperationlevels.c
|
|||
app/operations/gimpoperationoffset.c
|
||||
app/operations/gimpoperationposterize.c
|
||||
app/operations/gimpoperationsemiflatten.c
|
||||
app/operations/gimpoperationsettings.c
|
||||
app/operations/gimpoperationthreshold.c
|
||||
app/operations/gimpoperationthresholdalpha.c
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue