1 /* GIMP - The GNU Image Manipulation Program
2 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3 *
4 * gimp-operations.c
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20 #include "config.h"
21
22 #include <gdk-pixbuf/gdk-pixbuf.h>
23 #include <gegl.h>
24
25 #include "libgimpbase/gimpbase.h"
26
27 #include "operations-types.h"
28
29 #include "core/gimp.h"
30
31 #include "gimp-operations.h"
32
33 #include "gimpoperationborder.h"
34 #include "gimpoperationbuffersourcevalidate.h"
35 #include "gimpoperationcagecoefcalc.h"
36 #include "gimpoperationcagetransform.h"
37 #include "gimpoperationcomposecrop.h"
38 #include "gimpoperationequalize.h"
39 #include "gimpoperationfillsource.h"
40 #include "gimpoperationflood.h"
41 #include "gimpoperationgradient.h"
42 #include "gimpoperationgrow.h"
43 #include "gimpoperationhistogramsink.h"
44 #include "gimpoperationmaskcomponents.h"
45 #include "gimpoperationoffset.h"
46 #include "gimpoperationprofiletransform.h"
47 #include "gimpoperationscalarmultiply.h"
48 #include "gimpoperationsemiflatten.h"
49 #include "gimpoperationsetalpha.h"
50 #include "gimpoperationshrink.h"
51 #include "gimpoperationthresholdalpha.h"
52
53 #include "gimpoperationbrightnesscontrast.h"
54 #include "gimpoperationcolorbalance.h"
55 #include "gimpoperationcolorize.h"
56 #include "gimpoperationcurves.h"
57 #include "gimpoperationdesaturate.h"
58 #include "gimpoperationhuesaturation.h"
59 #include "gimpoperationlevels.h"
60 #include "gimpoperationposterize.h"
61 #include "gimpoperationthreshold.h"
62
63 #include "gimp-operation-config.h"
64 #include "gimpbrightnesscontrastconfig.h"
65 #include "gimpcolorbalanceconfig.h"
66 #include "gimpcurvesconfig.h"
67 #include "gimphuesaturationconfig.h"
68 #include "gimplevelsconfig.h"
69
70 #include "layer-modes-legacy/gimpoperationadditionlegacy.h"
71 #include "layer-modes-legacy/gimpoperationburnlegacy.h"
72 #include "layer-modes-legacy/gimpoperationdarkenonlylegacy.h"
73 #include "layer-modes-legacy/gimpoperationdifferencelegacy.h"
74 #include "layer-modes-legacy/gimpoperationdividelegacy.h"
75 #include "layer-modes-legacy/gimpoperationdodgelegacy.h"
76 #include "layer-modes-legacy/gimpoperationgrainextractlegacy.h"
77 #include "layer-modes-legacy/gimpoperationgrainmergelegacy.h"
78 #include "layer-modes-legacy/gimpoperationhardlightlegacy.h"
79 #include "layer-modes-legacy/gimpoperationhslcolorlegacy.h"
80 #include "layer-modes-legacy/gimpoperationhsvhuelegacy.h"
81 #include "layer-modes-legacy/gimpoperationhsvsaturationlegacy.h"
82 #include "layer-modes-legacy/gimpoperationhsvvaluelegacy.h"
83 #include "layer-modes-legacy/gimpoperationlightenonlylegacy.h"
84 #include "layer-modes-legacy/gimpoperationmultiplylegacy.h"
85 #include "layer-modes-legacy/gimpoperationscreenlegacy.h"
86 #include "layer-modes-legacy/gimpoperationsoftlightlegacy.h"
87 #include "layer-modes-legacy/gimpoperationsubtractlegacy.h"
88
89 #include "layer-modes/gimp-layer-modes.h"
90 #include "layer-modes/gimpoperationantierase.h"
91 #include "layer-modes/gimpoperationbehind.h"
92 #include "layer-modes/gimpoperationdissolve.h"
93 #include "layer-modes/gimpoperationerase.h"
94 #include "layer-modes/gimpoperationmerge.h"
95 #include "layer-modes/gimpoperationnormal.h"
96 #include "layer-modes/gimpoperationpassthrough.h"
97 #include "layer-modes/gimpoperationreplace.h"
98 #include "layer-modes/gimpoperationsplit.h"
99
100
101 static void
set_compat_file(GType type,const gchar * basename)102 set_compat_file (GType type,
103 const gchar *basename)
104 {
105 GFile *file = gimp_directory_file ("tool-options", basename, NULL);
106 GQuark quark = g_quark_from_static_string ("compat-file");
107
108 g_type_set_qdata (type, quark, file);
109 }
110
111 static void
set_settings_folder(GType type,const gchar * basename)112 set_settings_folder (GType type,
113 const gchar *basename)
114 {
115 GFile *file = gimp_directory_file (basename, NULL);
116 GQuark quark = g_quark_from_static_string ("settings-folder");
117
118 g_type_set_qdata (type, quark, file);
119 }
120
121 void
gimp_operations_init(Gimp * gimp)122 gimp_operations_init (Gimp *gimp)
123 {
124 g_return_if_fail (GIMP_IS_GIMP (gimp));
125
126 gimp_layer_modes_init ();
127
128 g_type_class_ref (GIMP_TYPE_OPERATION_BORDER);
129 g_type_class_ref (GIMP_TYPE_OPERATION_BUFFER_SOURCE_VALIDATE);
130 g_type_class_ref (GIMP_TYPE_OPERATION_CAGE_COEF_CALC);
131 g_type_class_ref (GIMP_TYPE_OPERATION_CAGE_TRANSFORM);
132 g_type_class_ref (GIMP_TYPE_OPERATION_COMPOSE_CROP);
133 g_type_class_ref (GIMP_TYPE_OPERATION_EQUALIZE);
134 g_type_class_ref (GIMP_TYPE_OPERATION_FILL_SOURCE);
135 g_type_class_ref (GIMP_TYPE_OPERATION_FLOOD);
136 g_type_class_ref (GIMP_TYPE_OPERATION_GRADIENT);
137 g_type_class_ref (GIMP_TYPE_OPERATION_GROW);
138 g_type_class_ref (GIMP_TYPE_OPERATION_HISTOGRAM_SINK);
139 g_type_class_ref (GIMP_TYPE_OPERATION_MASK_COMPONENTS);
140 g_type_class_ref (GIMP_TYPE_OPERATION_OFFSET);
141 g_type_class_ref (GIMP_TYPE_OPERATION_PROFILE_TRANSFORM);
142 g_type_class_ref (GIMP_TYPE_OPERATION_SCALAR_MULTIPLY);
143 g_type_class_ref (GIMP_TYPE_OPERATION_SEMI_FLATTEN);
144 g_type_class_ref (GIMP_TYPE_OPERATION_SET_ALPHA);
145 g_type_class_ref (GIMP_TYPE_OPERATION_SHRINK);
146 g_type_class_ref (GIMP_TYPE_OPERATION_THRESHOLD_ALPHA);
147
148 g_type_class_ref (GIMP_TYPE_OPERATION_BRIGHTNESS_CONTRAST);
149 g_type_class_ref (GIMP_TYPE_OPERATION_COLOR_BALANCE);
150 g_type_class_ref (GIMP_TYPE_OPERATION_COLORIZE);
151 g_type_class_ref (GIMP_TYPE_OPERATION_CURVES);
152 g_type_class_ref (GIMP_TYPE_OPERATION_DESATURATE);
153 g_type_class_ref (GIMP_TYPE_OPERATION_HUE_SATURATION);
154 g_type_class_ref (GIMP_TYPE_OPERATION_LEVELS);
155 g_type_class_ref (GIMP_TYPE_OPERATION_POSTERIZE);
156 g_type_class_ref (GIMP_TYPE_OPERATION_THRESHOLD);
157
158 g_type_class_ref (GIMP_TYPE_OPERATION_NORMAL);
159 g_type_class_ref (GIMP_TYPE_OPERATION_DISSOLVE);
160 g_type_class_ref (GIMP_TYPE_OPERATION_BEHIND);
161 g_type_class_ref (GIMP_TYPE_OPERATION_MULTIPLY_LEGACY);
162 g_type_class_ref (GIMP_TYPE_OPERATION_SCREEN_LEGACY);
163 g_type_class_ref (GIMP_TYPE_OPERATION_DIFFERENCE_LEGACY);
164 g_type_class_ref (GIMP_TYPE_OPERATION_ADDITION_LEGACY);
165 g_type_class_ref (GIMP_TYPE_OPERATION_SUBTRACT_LEGACY);
166 g_type_class_ref (GIMP_TYPE_OPERATION_DARKEN_ONLY_LEGACY);
167 g_type_class_ref (GIMP_TYPE_OPERATION_LIGHTEN_ONLY_LEGACY);
168 g_type_class_ref (GIMP_TYPE_OPERATION_HSV_HUE_LEGACY);
169 g_type_class_ref (GIMP_TYPE_OPERATION_HSV_SATURATION_LEGACY);
170 g_type_class_ref (GIMP_TYPE_OPERATION_HSL_COLOR_LEGACY);
171 g_type_class_ref (GIMP_TYPE_OPERATION_HSV_VALUE_LEGACY);
172 g_type_class_ref (GIMP_TYPE_OPERATION_DIVIDE_LEGACY);
173 g_type_class_ref (GIMP_TYPE_OPERATION_DODGE_LEGACY);
174 g_type_class_ref (GIMP_TYPE_OPERATION_BURN_LEGACY);
175 g_type_class_ref (GIMP_TYPE_OPERATION_HARDLIGHT_LEGACY);
176 g_type_class_ref (GIMP_TYPE_OPERATION_SOFTLIGHT_LEGACY);
177 g_type_class_ref (GIMP_TYPE_OPERATION_GRAIN_EXTRACT_LEGACY);
178 g_type_class_ref (GIMP_TYPE_OPERATION_GRAIN_MERGE_LEGACY);
179 g_type_class_ref (GIMP_TYPE_OPERATION_ERASE);
180 g_type_class_ref (GIMP_TYPE_OPERATION_MERGE);
181 g_type_class_ref (GIMP_TYPE_OPERATION_SPLIT);
182 g_type_class_ref (GIMP_TYPE_OPERATION_PASS_THROUGH);
183 g_type_class_ref (GIMP_TYPE_OPERATION_REPLACE);
184 g_type_class_ref (GIMP_TYPE_OPERATION_ANTI_ERASE);
185
186 gimp_operation_config_register (gimp,
187 "gimp:brightness-contrast",
188 GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG);
189 set_compat_file (GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG,
190 "gimp-brightness-contrast-tool.settings");
191 set_settings_folder (GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG,
192 "brightness-contrast");
193
194 gimp_operation_config_register (gimp,
195 "gimp:color-balance",
196 GIMP_TYPE_COLOR_BALANCE_CONFIG);
197 set_compat_file (GIMP_TYPE_COLOR_BALANCE_CONFIG,
198 "gimp-color-balance-tool.settings");
199 set_settings_folder (GIMP_TYPE_COLOR_BALANCE_CONFIG,
200 "color-balance");
201
202 gimp_operation_config_register (gimp,
203 "gimp:curves",
204 GIMP_TYPE_CURVES_CONFIG);
205 set_compat_file (GIMP_TYPE_CURVES_CONFIG,
206 "gimp-curves-tool.settings");
207 set_settings_folder (GIMP_TYPE_CURVES_CONFIG,
208 "curves");
209
210 gimp_operation_config_register (gimp,
211 "gimp:hue-saturation",
212 GIMP_TYPE_HUE_SATURATION_CONFIG);
213 set_compat_file (GIMP_TYPE_HUE_SATURATION_CONFIG,
214 "gimp-hue-saturation-tool.settings");
215 set_settings_folder (GIMP_TYPE_HUE_SATURATION_CONFIG,
216 "hue-saturation");
217
218 gimp_operation_config_register (gimp,
219 "gimp:levels",
220 GIMP_TYPE_LEVELS_CONFIG);
221 set_compat_file (GIMP_TYPE_LEVELS_CONFIG,
222 "gimp-levels-tool.settings");
223 set_settings_folder (GIMP_TYPE_LEVELS_CONFIG,
224 "levels");
225 }
226