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
#include "plug-in/plug-in-progress.h"
31
#include "plug-in/plug-in.h"
33
static ProcRecord progress_init_proc;
34
static ProcRecord progress_update_proc;
35
static ProcRecord progress_install_proc;
36
static ProcRecord progress_uninstall_proc;
37
static ProcRecord progress_cancel_proc;
32
#include "plug-in/gimpplugin-progress.h"
33
#include "plug-in/gimpplugin.h"
34
#include "plug-in/gimppluginmanager.h"
36
#include "internal_procs.h"
40
progress_init_invoker (GimpProcedure *procedure,
43
GimpProgress *progress,
44
const GValueArray *args)
46
gboolean success = TRUE;
50
message = g_value_get_string (&args->values[0]);
51
gdisplay = gimp_value_get_display (&args->values[1], gimp);
55
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
57
if (plug_in && plug_in->open)
59
if (! gimp->no_interface)
60
gimp_plug_in_progress_start (plug_in, message, gdisplay);
66
return gimp_procedure_get_return_values (procedure, success);
70
progress_update_invoker (GimpProcedure *procedure,
73
GimpProgress *progress,
74
const GValueArray *args)
76
gboolean success = TRUE;
79
percentage = g_value_get_double (&args->values[0]);
83
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
85
if (plug_in && plug_in->open)
87
if (! gimp->no_interface)
88
gimp_plug_in_progress_set_value (plug_in, percentage);
94
return gimp_procedure_get_return_values (procedure, success);
98
progress_pulse_invoker (GimpProcedure *procedure,
100
GimpContext *context,
101
GimpProgress *progress,
102
const GValueArray *args)
104
gboolean success = TRUE;
105
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
107
if (plug_in && plug_in->open)
109
if (! gimp->no_interface)
110
gimp_plug_in_progress_pulse (plug_in);
115
return gimp_procedure_get_return_values (procedure, success);
119
progress_set_text_invoker (GimpProcedure *procedure,
121
GimpContext *context,
122
GimpProgress *progress,
123
const GValueArray *args)
125
gboolean success = TRUE;
126
const gchar *message;
128
message = g_value_get_string (&args->values[0]);
132
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
134
if (plug_in && plug_in->open)
136
if (! gimp->no_interface)
137
gimp_plug_in_progress_set_text (plug_in, message);
143
return gimp_procedure_get_return_values (procedure, success);
147
progress_get_window_handle_invoker (GimpProcedure *procedure,
149
GimpContext *context,
150
GimpProgress *progress,
151
const GValueArray *args)
153
gboolean success = TRUE;
154
GValueArray *return_vals;
157
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
159
if (plug_in && plug_in->open)
161
if (! gimp->no_interface)
162
window = gimp_plug_in_progress_get_window (plug_in);
167
return_vals = gimp_procedure_get_return_values (procedure, success);
170
g_value_set_int (&return_vals->values[1], window);
176
progress_install_invoker (GimpProcedure *procedure,
178
GimpContext *context,
179
GimpProgress *progress,
180
const GValueArray *args)
182
gboolean success = TRUE;
183
const gchar *progress_callback;
185
progress_callback = g_value_get_string (&args->values[0]);
189
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
191
if (plug_in && plug_in->open)
192
success = gimp_plug_in_progress_install (plug_in, progress_callback);
197
return gimp_procedure_get_return_values (procedure, success);
201
progress_uninstall_invoker (GimpProcedure *procedure,
203
GimpContext *context,
204
GimpProgress *progress,
205
const GValueArray *args)
207
gboolean success = TRUE;
208
const gchar *progress_callback;
210
progress_callback = g_value_get_string (&args->values[0]);
214
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
216
if (plug_in && plug_in->open)
217
success = gimp_plug_in_progress_uninstall (plug_in, progress_callback);
222
return gimp_procedure_get_return_values (procedure, success);
226
progress_cancel_invoker (GimpProcedure *procedure,
228
GimpContext *context,
229
GimpProgress *progress,
230
const GValueArray *args)
232
gboolean success = TRUE;
233
const gchar *progress_callback;
235
progress_callback = g_value_get_string (&args->values[0]);
239
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
241
if (plug_in && plug_in->open)
242
success = gimp_plug_in_progress_cancel (plug_in, progress_callback);
247
return gimp_procedure_get_return_values (procedure, success);
40
register_progress_procs (Gimp *gimp)
42
procedural_db_register (gimp, &progress_init_proc);
43
procedural_db_register (gimp, &progress_update_proc);
44
procedural_db_register (gimp, &progress_install_proc);
45
procedural_db_register (gimp, &progress_uninstall_proc);
46
procedural_db_register (gimp, &progress_cancel_proc);
50
progress_init_invoker (Gimp *gimp,
52
GimpProgress *progress,
55
gboolean success = TRUE;
59
message = (gchar *) args[0].value.pdb_pointer;
60
if (message && !g_utf8_validate (message, -1, NULL))
63
gdisplay = args[1].value.pdb_int;
67
if (gimp->current_plug_in && gimp->current_plug_in->open)
69
if (! gimp->no_interface)
70
plug_in_progress_start (gimp->current_plug_in, message, gdisplay);
76
return procedural_db_return_args (&progress_init_proc, success);
79
static ProcArg progress_init_inargs[] =
84
"Message to use in the progress dialog"
89
"GimpDisplay to update progressbar in, or -1 for a seperate window"
93
static ProcRecord progress_init_proc =
96
"Initializes the progress bar for the current plug-in.",
97
"Initializes the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.",
98
"Spencer Kimball & Peter Mattis",
99
"Spencer Kimball & Peter Mattis",
104
progress_init_inargs,
107
{ { progress_init_invoker } }
111
progress_update_invoker (Gimp *gimp,
112
GimpContext *context,
113
GimpProgress *progress,
116
gboolean success = TRUE;
119
percentage = args[0].value.pdb_float;
121
if (gimp->current_plug_in && gimp->current_plug_in->open)
123
if (! gimp->no_interface)
124
plug_in_progress_update (gimp->current_plug_in, percentage);
129
return procedural_db_return_args (&progress_update_proc, success);
132
static ProcArg progress_update_inargs[] =
137
"Percentage of progress completed which must be between 0.0 and 1.0"
141
static ProcRecord progress_update_proc =
143
"gimp_progress_update",
144
"Updates the progress bar for the current plug-in.",
145
"Updates the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.",
146
"Spencer Kimball & Peter Mattis",
147
"Spencer Kimball & Peter Mattis",
152
progress_update_inargs,
155
{ { progress_update_invoker } }
159
progress_install_invoker (Gimp *gimp,
160
GimpContext *context,
161
GimpProgress *progress,
164
gboolean success = TRUE;
165
gchar *progress_callback;
167
progress_callback = (gchar *) args[0].value.pdb_pointer;
168
if (progress_callback == NULL || !g_utf8_validate (progress_callback, -1, NULL))
173
if (gimp->current_plug_in && gimp->current_plug_in->open)
174
success = plug_in_progress_install (gimp->current_plug_in,
180
return procedural_db_return_args (&progress_install_proc, success);
183
static ProcArg progress_install_inargs[] =
188
"The callback PDB proc to call"
192
static ProcRecord progress_install_proc =
194
"gimp_progress_install",
195
"Installs a progress callback for the current plug-in.",
196
"This function installs a temporary PDB procedure which will handle all progress calls made by this plug-in and any procedure it calls. Calling this function multiple times simply replaces the old progress callbacks.",
197
"Michael Natterer <mitch@gimp.org>",
203
progress_install_inargs,
206
{ { progress_install_invoker } }
210
progress_uninstall_invoker (Gimp *gimp,
211
GimpContext *context,
212
GimpProgress *progress,
215
gboolean success = TRUE;
216
gchar *progress_callback;
218
progress_callback = (gchar *) args[0].value.pdb_pointer;
219
if (progress_callback == NULL || !g_utf8_validate (progress_callback, -1, NULL))
224
if (gimp->current_plug_in && gimp->current_plug_in->open)
225
success = plug_in_progress_uninstall (gimp->current_plug_in,
231
return procedural_db_return_args (&progress_uninstall_proc, success);
234
static ProcArg progress_uninstall_inargs[] =
239
"The name of the callback registered for this progress"
243
static ProcRecord progress_uninstall_proc =
245
"gimp_progress_uninstall",
246
"Uninstalls the progress callback for the current plug-in.",
247
"This function uninstalls any progress callback installed with gimp_progress_install() before.",
248
"Michael Natterer <mitch@gimp.org>",
254
progress_uninstall_inargs,
257
{ { progress_uninstall_invoker } }
261
progress_cancel_invoker (Gimp *gimp,
262
GimpContext *context,
263
GimpProgress *progress,
266
gboolean success = TRUE;
267
gchar *progress_callback;
269
progress_callback = (gchar *) args[0].value.pdb_pointer;
270
if (progress_callback == NULL || !g_utf8_validate (progress_callback, -1, NULL))
275
if (gimp->current_plug_in && gimp->current_plug_in->open)
276
success = plug_in_progress_cancel (gimp->current_plug_in,
282
return procedural_db_return_args (&progress_cancel_proc, success);
285
static ProcArg progress_cancel_inargs[] =
290
"The name of the callback registered for this progress"
294
static ProcRecord progress_cancel_proc =
296
"gimp_progress_cancel",
297
"Cancels a running progress.",
298
"This function cancels the currently running progress.",
299
"Michael Natterer <mitch@gimp.org>",
305
progress_cancel_inargs,
308
{ { progress_cancel_invoker } }
251
register_progress_procs (GimpPDB *pdb)
253
GimpProcedure *procedure;
258
procedure = gimp_procedure_new (progress_init_invoker);
259
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-progress-init");
260
gimp_procedure_set_static_strings (procedure,
261
"gimp-progress-init",
262
"Initializes the progress bar for the current plug-in.",
263
"Initializes the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.",
264
"Spencer Kimball & Peter Mattis",
265
"Spencer Kimball & Peter Mattis",
268
gimp_procedure_add_argument (procedure,
269
gimp_param_spec_string ("message",
271
"Message to use in the progress dialog",
274
GIMP_PARAM_READWRITE));
275
gimp_procedure_add_argument (procedure,
276
gimp_param_spec_display_id ("gdisplay",
278
"GimpDisplay to update progressbar in, or -1 for a seperate window",
280
GIMP_PARAM_READWRITE));
281
gimp_pdb_register_procedure (pdb, procedure);
282
g_object_unref (procedure);
285
* gimp-progress-update
287
procedure = gimp_procedure_new (progress_update_invoker);
288
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-progress-update");
289
gimp_procedure_set_static_strings (procedure,
290
"gimp-progress-update",
291
"Updates the progress bar for the current plug-in.",
292
"Updates the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.",
293
"Spencer Kimball & Peter Mattis",
294
"Spencer Kimball & Peter Mattis",
297
gimp_procedure_add_argument (procedure,
298
g_param_spec_double ("percentage",
300
"Percentage of progress completed which must be between 0.0 and 1.0",
301
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
302
GIMP_PARAM_READWRITE));
303
gimp_pdb_register_procedure (pdb, procedure);
304
g_object_unref (procedure);
307
* gimp-progress-pulse
309
procedure = gimp_procedure_new (progress_pulse_invoker);
310
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-progress-pulse");
311
gimp_procedure_set_static_strings (procedure,
312
"gimp-progress-pulse",
313
"Pulses the progress bar for the current plug-in.",
314
"Updates the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in. Use this function instead of 'gimp-progress-update' if you cannot tell how much progress has been made. This usually causes the the progress bar to enter \"activity mode\", where a block bounces back and forth.",
315
"Sven Neumann <sven@gimp.org>",
319
gimp_pdb_register_procedure (pdb, procedure);
320
g_object_unref (procedure);
323
* gimp-progress-set-text
325
procedure = gimp_procedure_new (progress_set_text_invoker);
326
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-progress-set-text");
327
gimp_procedure_set_static_strings (procedure,
328
"gimp-progress-set-text",
329
"Changes the text in the progress bar for the current plug-in.",
330
"This function allows to change the text in the progress bar for the current plug-in. Unlike 'gimp-progress-init' it does not change the displayed value.",
331
"Sven Neumann <sven@gimp.org>",
335
gimp_procedure_add_argument (procedure,
336
gimp_param_spec_string ("message",
338
"Message to use in the progress dialog",
341
GIMP_PARAM_READWRITE));
342
gimp_pdb_register_procedure (pdb, procedure);
343
g_object_unref (procedure);
346
* gimp-progress-get-window-handle
348
procedure = gimp_procedure_new (progress_get_window_handle_invoker);
349
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-progress-get-window-handle");
350
gimp_procedure_set_static_strings (procedure,
351
"gimp-progress-get-window-handle",
352
"Returns the native window ID of the toplevel window this plug-in's progress is displayed in.",
353
"This function returns the native window ID of the toplevel window this plug-in\'s progress is displayed in.",
354
"Michael Natterer <mitch@gimp.org>",
358
gimp_procedure_add_return_value (procedure,
359
gimp_param_spec_int32 ("window",
361
"The progress bar's toplevel window",
362
G_MININT32, G_MAXINT32, 0,
363
GIMP_PARAM_READWRITE));
364
gimp_pdb_register_procedure (pdb, procedure);
365
g_object_unref (procedure);
368
* gimp-progress-install
370
procedure = gimp_procedure_new (progress_install_invoker);
371
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-progress-install");
372
gimp_procedure_set_static_strings (procedure,
373
"gimp-progress-install",
374
"Installs a progress callback for the current plug-in.",
375
"This function installs a temporary PDB procedure which will handle all progress calls made by this plug-in and any procedure it calls. Calling this function multiple times simply replaces the old progress callbacks.",
376
"Michael Natterer <mitch@gimp.org>",
380
gimp_procedure_add_argument (procedure,
381
gimp_param_spec_string ("progress-callback",
383
"The callback PDB proc to call",
386
GIMP_PARAM_READWRITE));
387
gimp_pdb_register_procedure (pdb, procedure);
388
g_object_unref (procedure);
391
* gimp-progress-uninstall
393
procedure = gimp_procedure_new (progress_uninstall_invoker);
394
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-progress-uninstall");
395
gimp_procedure_set_static_strings (procedure,
396
"gimp-progress-uninstall",
397
"Uninstalls the progress callback for the current plug-in.",
398
"This function uninstalls any progress callback installed with 'gimp-progress-install' before.",
399
"Michael Natterer <mitch@gimp.org>",
403
gimp_procedure_add_argument (procedure,
404
gimp_param_spec_string ("progress-callback",
406
"The name of the callback registered for this progress",
409
GIMP_PARAM_READWRITE));
410
gimp_pdb_register_procedure (pdb, procedure);
411
g_object_unref (procedure);
414
* gimp-progress-cancel
416
procedure = gimp_procedure_new (progress_cancel_invoker);
417
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-progress-cancel");
418
gimp_procedure_set_static_strings (procedure,
419
"gimp-progress-cancel",
420
"Cancels a running progress.",
421
"This function cancels the currently running progress.",
422
"Michael Natterer <mitch@gimp.org>",
426
gimp_procedure_add_argument (procedure,
427
gimp_param_spec_string ("progress-callback",
429
"The name of the callback registered for this progress",
432
GIMP_PARAM_READWRITE));
433
gimp_pdb_register_procedure (pdb, procedure);
434
g_object_unref (procedure);