24
24
#include <glib-object.h>
26
26
#include "pdb-types.h"
27
#include "procedural_db.h"
28
#include "gimpprocedure.h"
29
#include "core/gimpparamspecs.h"
29
31
#include "core/gimp.h"
30
32
#include "core/gimpdatafactory.h"
31
33
#include "core/gimpgradient.h"
33
static ProcRecord gradients_popup_proc;
34
static ProcRecord gradients_close_popup_proc;
35
static ProcRecord gradients_set_popup_proc;
38
register_gradient_select_procs (Gimp *gimp)
40
procedural_db_register (gimp, &gradients_popup_proc);
41
procedural_db_register (gimp, &gradients_close_popup_proc);
42
procedural_db_register (gimp, &gradients_set_popup_proc);
46
gradients_popup_invoker (Gimp *gimp,
48
GimpProgress *progress,
35
#include "internal_procs.h"
39
gradients_popup_invoker (GimpProcedure *procedure,
42
GimpProgress *progress,
43
const GValueArray *args)
51
45
gboolean success = TRUE;
52
gchar *gradient_callback;
54
gchar *initial_gradient;
46
const gchar *gradient_callback;
47
const gchar *popup_title;
48
const gchar *initial_gradient;
55
49
gint32 sample_size;
57
gradient_callback = (gchar *) args[0].value.pdb_pointer;
58
if (gradient_callback == NULL || !g_utf8_validate (gradient_callback, -1, NULL))
61
popup_title = (gchar *) args[1].value.pdb_pointer;
62
if (popup_title == NULL || !g_utf8_validate (popup_title, -1, NULL))
65
initial_gradient = (gchar *) args[2].value.pdb_pointer;
66
if (initial_gradient && !g_utf8_validate (initial_gradient, -1, NULL))
69
sample_size = args[3].value.pdb_int;
70
if (sample_size <= 0 || sample_size > 10000)
71
sample_size = GIMP_GRADIENT_DEFAULT_SAMPLE_SIZE;
51
gradient_callback = g_value_get_string (&args->values[0]);
52
popup_title = g_value_get_string (&args->values[1]);
53
initial_gradient = g_value_get_string (&args->values[2]);
54
sample_size = g_value_get_int (&args->values[3]);
58
if (sample_size < 1 || sample_size > 10000)
59
sample_size = GIMP_GRADIENT_DEFAULT_SAMPLE_SIZE;
75
61
if (gimp->no_interface ||
76
! procedural_db_lookup (gimp, gradient_callback) ||
77
! gimp_pdb_dialog_new (gimp, context, gimp->gradient_factory->container,
62
! gimp_pdb_lookup_procedure (gimp->pdb, gradient_callback) ||
63
! gimp_pdb_dialog_new (gimp, context, progress,
64
gimp->gradient_factory->container,
78
65
popup_title, gradient_callback, initial_gradient,
79
66
"sample-size", sample_size,
84
return procedural_db_return_args (&gradients_popup_proc, success);
71
return gimp_procedure_get_return_values (procedure, success);
87
static ProcArg gradients_popup_inargs[] =
92
"The callback PDB proc to call when gradient selection is made"
97
"Title to give the gradient popup window"
102
"The name of the pattern to set as the first selected"
107
"Size of the sample to return when the gradient is changed (0 < sample_size <= 10000)"
111
static ProcRecord gradients_popup_proc =
113
"gimp_gradients_popup",
114
"Invokes the Gimp gradients selection.",
115
"This procedure popups the gradients selection dialog.",
122
gradients_popup_inargs,
125
{ { gradients_popup_invoker } }
129
gradients_close_popup_invoker (Gimp *gimp,
130
GimpContext *context,
131
GimpProgress *progress,
75
gradients_close_popup_invoker (GimpProcedure *procedure,
78
GimpProgress *progress,
79
const GValueArray *args)
134
81
gboolean success = TRUE;
135
gchar *gradient_callback;
82
const gchar *gradient_callback;
137
gradient_callback = (gchar *) args[0].value.pdb_pointer;
138
if (gradient_callback == NULL || !g_utf8_validate (gradient_callback, -1, NULL))
84
gradient_callback = g_value_get_string (&args->values[0]);
143
88
if (gimp->no_interface ||
144
! procedural_db_lookup (gimp, gradient_callback) ||
89
! gimp_pdb_lookup_procedure (gimp->pdb, gradient_callback) ||
145
90
! gimp_pdb_dialog_close (gimp, gimp->gradient_factory->container,
146
91
gradient_callback))
150
return procedural_db_return_args (&gradients_close_popup_proc, success);
95
return gimp_procedure_get_return_values (procedure, success);
153
static ProcArg gradients_close_popup_inargs[] =
158
"The name of the callback registered for this popup"
162
static ProcRecord gradients_close_popup_proc =
164
"gimp_gradients_close_popup",
165
"Popdown the Gimp gradient selection.",
166
"This procedure closes an opened gradient selection dialog.",
173
gradients_close_popup_inargs,
176
{ { gradients_close_popup_invoker } }
180
gradients_set_popup_invoker (Gimp *gimp,
181
GimpContext *context,
182
GimpProgress *progress,
99
gradients_set_popup_invoker (GimpProcedure *procedure,
101
GimpContext *context,
102
GimpProgress *progress,
103
const GValueArray *args)
185
105
gboolean success = TRUE;
186
gchar *gradient_callback;
187
gchar *gradient_name;
189
gradient_callback = (gchar *) args[0].value.pdb_pointer;
190
if (gradient_callback == NULL || !g_utf8_validate (gradient_callback, -1, NULL))
193
gradient_name = (gchar *) args[1].value.pdb_pointer;
194
if (gradient_name == NULL || !g_utf8_validate (gradient_name, -1, NULL))
106
const gchar *gradient_callback;
107
const gchar *gradient_name;
109
gradient_callback = g_value_get_string (&args->values[0]);
110
gradient_name = g_value_get_string (&args->values[1]);
199
114
if (gimp->no_interface ||
200
! procedural_db_lookup (gimp, gradient_callback) ||
115
! gimp_pdb_lookup_procedure (gimp->pdb, gradient_callback) ||
201
116
! gimp_pdb_dialog_set (gimp, gimp->gradient_factory->container,
202
117
gradient_callback, gradient_name,
207
return procedural_db_return_args (&gradients_set_popup_proc, success);
210
static ProcArg gradients_set_popup_inargs[] =
215
"The name of the callback registered for this popup"
220
"The name of the gradient to set as selected"
224
static ProcRecord gradients_set_popup_proc =
226
"gimp_gradients_set_popup",
227
"Sets the current gradient selection in a popup.",
228
"Sets the current gradient selection in a popup.",
235
gradients_set_popup_inargs,
238
{ { gradients_set_popup_invoker } }
122
return gimp_procedure_get_return_values (procedure, success);
126
register_gradient_select_procs (GimpPDB *pdb)
128
GimpProcedure *procedure;
131
* gimp-gradients-popup
133
procedure = gimp_procedure_new (gradients_popup_invoker);
134
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-gradients-popup");
135
gimp_procedure_set_static_strings (procedure,
136
"gimp-gradients-popup",
137
"Invokes the Gimp gradients selection.",
138
"This procedure opens the gradient selection dialog.",
143
gimp_procedure_add_argument (procedure,
144
gimp_param_spec_string ("gradient-callback",
146
"The callback PDB proc to call when gradient selection is made",
149
GIMP_PARAM_READWRITE));
150
gimp_procedure_add_argument (procedure,
151
gimp_param_spec_string ("popup-title",
153
"Title of the gradient selection dialog",
156
GIMP_PARAM_READWRITE));
157
gimp_procedure_add_argument (procedure,
158
gimp_param_spec_string ("initial-gradient",
160
"The name of the gradient to set as the first selected",
163
GIMP_PARAM_READWRITE));
164
gimp_procedure_add_argument (procedure,
165
gimp_param_spec_int32 ("sample-size",
167
"Size of the sample to return when the gradient is changed",
169
GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
170
gimp_pdb_register_procedure (pdb, procedure);
171
g_object_unref (procedure);
174
* gimp-gradients-close-popup
176
procedure = gimp_procedure_new (gradients_close_popup_invoker);
177
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-gradients-close-popup");
178
gimp_procedure_set_static_strings (procedure,
179
"gimp-gradients-close-popup",
180
"Close the gradient selection dialog.",
181
"This procedure closes an opened gradient selection dialog.",
186
gimp_procedure_add_argument (procedure,
187
gimp_param_spec_string ("gradient-callback",
189
"The name of the callback registered for this pop-up",
192
GIMP_PARAM_READWRITE));
193
gimp_pdb_register_procedure (pdb, procedure);
194
g_object_unref (procedure);
197
* gimp-gradients-set-popup
199
procedure = gimp_procedure_new (gradients_set_popup_invoker);
200
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-gradients-set-popup");
201
gimp_procedure_set_static_strings (procedure,
202
"gimp-gradients-set-popup",
203
"Sets the current gradient in a gradient selection dialog.",
204
"Sets the current gradient in a gradient selection dialog.",
209
gimp_procedure_add_argument (procedure,
210
gimp_param_spec_string ("gradient-callback",
212
"The name of the callback registered for this pop-up",
215
GIMP_PARAM_READWRITE));
216
gimp_procedure_add_argument (procedure,
217
gimp_param_spec_string ("gradient-name",
219
"The name of the gradient to set as selected",
222
GIMP_PARAM_READWRITE));
223
gimp_pdb_register_procedure (pdb, procedure);
224
g_object_unref (procedure);