1 /* LIBGIMP - The GIMP Library
2 * Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
3 *
4 * gimpprogress_pdb.c
5 *
6 * This library is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
10 *
11 * This library 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 GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library. If not, see
18 * <https://www.gnu.org/licenses/>.
19 */
20
21 /* NOTE: This file is auto-generated by pdbgen.pl */
22
23 #include "config.h"
24
25 #include "gimp.h"
26
27
28 /**
29 * SECTION: gimpprogress
30 * @title: gimpprogress
31 * @short_description: Functions for embedding the progress bar into a plug-in's GUI.
32 *
33 * Functions for embedding the progress bar into a plug-in's GUI.
34 **/
35
36
37 /**
38 * _gimp_progress_init:
39 * @message: Message to use in the progress dialog.
40 * @gdisplay_ID: GimpDisplay to update progressbar in, or -1 for a separate window.
41 *
42 * Initializes the progress bar for the current plug-in.
43 *
44 * Initializes the progress bar for the current plug-in. It is only
45 * valid to call this procedure from a plug-in.
46 *
47 * Returns: TRUE on success.
48 **/
49 gboolean
_gimp_progress_init(const gchar * message,gint32 gdisplay_ID)50 _gimp_progress_init (const gchar *message,
51 gint32 gdisplay_ID)
52 {
53 GimpParam *return_vals;
54 gint nreturn_vals;
55 gboolean success = TRUE;
56
57 return_vals = gimp_run_procedure ("gimp-progress-init",
58 &nreturn_vals,
59 GIMP_PDB_STRING, message,
60 GIMP_PDB_DISPLAY, gdisplay_ID,
61 GIMP_PDB_END);
62
63 success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
64
65 gimp_destroy_params (return_vals, nreturn_vals);
66
67 return success;
68 }
69
70 /**
71 * _gimp_progress_update:
72 * @percentage: Percentage of progress completed which must be between 0.0 and 1.0.
73 *
74 * Updates the progress bar for the current plug-in.
75 *
76 * Updates the progress bar for the current plug-in. It is only valid
77 * to call this procedure from a plug-in.
78 *
79 * Returns: TRUE on success.
80 **/
81 gboolean
_gimp_progress_update(gdouble percentage)82 _gimp_progress_update (gdouble percentage)
83 {
84 GimpParam *return_vals;
85 gint nreturn_vals;
86 gboolean success = TRUE;
87
88 return_vals = gimp_run_procedure ("gimp-progress-update",
89 &nreturn_vals,
90 GIMP_PDB_FLOAT, percentage,
91 GIMP_PDB_END);
92
93 success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
94
95 gimp_destroy_params (return_vals, nreturn_vals);
96
97 return success;
98 }
99
100 /**
101 * gimp_progress_pulse:
102 *
103 * Pulses the progress bar for the current plug-in.
104 *
105 * Updates the progress bar for the current plug-in. It is only valid
106 * to call this procedure from a plug-in. Use this function instead of
107 * gimp_progress_update() if you cannot tell how much progress has been
108 * made. This usually causes the the progress bar to enter \"activity
109 * mode\", where a block bounces back and forth.
110 *
111 * Returns: TRUE on success.
112 *
113 * Since: 2.4
114 **/
115 gboolean
gimp_progress_pulse(void)116 gimp_progress_pulse (void)
117 {
118 GimpParam *return_vals;
119 gint nreturn_vals;
120 gboolean success = TRUE;
121
122 return_vals = gimp_run_procedure ("gimp-progress-pulse",
123 &nreturn_vals,
124 GIMP_PDB_END);
125
126 success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
127
128 gimp_destroy_params (return_vals, nreturn_vals);
129
130 return success;
131 }
132
133 /**
134 * gimp_progress_set_text:
135 * @message: Message to use in the progress dialog.
136 *
137 * Changes the text in the progress bar for the current plug-in.
138 *
139 * This function changes the text in the progress bar for the current
140 * plug-in. Unlike gimp_progress_init() it does not change the
141 * displayed value.
142 *
143 * Returns: TRUE on success.
144 *
145 * Since: 2.4
146 **/
147 gboolean
gimp_progress_set_text(const gchar * message)148 gimp_progress_set_text (const gchar *message)
149 {
150 GimpParam *return_vals;
151 gint nreturn_vals;
152 gboolean success = TRUE;
153
154 return_vals = gimp_run_procedure ("gimp-progress-set-text",
155 &nreturn_vals,
156 GIMP_PDB_STRING, message,
157 GIMP_PDB_END);
158
159 success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
160
161 gimp_destroy_params (return_vals, nreturn_vals);
162
163 return success;
164 }
165
166 /**
167 * gimp_progress_end:
168 *
169 * Ends the progress bar for the current plug-in.
170 *
171 * Ends the progress display for the current plug-in. Most plug-ins
172 * don't need to call this, they just exit when the work is done. It is
173 * only valid to call this procedure from a plug-in.
174 *
175 * Returns: TRUE on success.
176 *
177 * Since: 2.4
178 **/
179 gboolean
gimp_progress_end(void)180 gimp_progress_end (void)
181 {
182 GimpParam *return_vals;
183 gint nreturn_vals;
184 gboolean success = TRUE;
185
186 return_vals = gimp_run_procedure ("gimp-progress-end",
187 &nreturn_vals,
188 GIMP_PDB_END);
189
190 success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
191
192 gimp_destroy_params (return_vals, nreturn_vals);
193
194 return success;
195 }
196
197 /**
198 * gimp_progress_get_window_handle:
199 *
200 * Returns the native window ID of the toplevel window this plug-in's
201 * progress is displayed in.
202 *
203 * This function returns the native window ID of the toplevel window
204 * this plug-in\'s progress is displayed in.
205 *
206 * Returns: The progress bar's toplevel window.
207 *
208 * Since: 2.2
209 **/
210 gint
gimp_progress_get_window_handle(void)211 gimp_progress_get_window_handle (void)
212 {
213 GimpParam *return_vals;
214 gint nreturn_vals;
215 gint window = 0;
216
217 return_vals = gimp_run_procedure ("gimp-progress-get-window-handle",
218 &nreturn_vals,
219 GIMP_PDB_END);
220
221 if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
222 window = return_vals[1].data.d_int32;
223
224 gimp_destroy_params (return_vals, nreturn_vals);
225
226 return window;
227 }
228
229 /**
230 * _gimp_progress_install:
231 * @progress_callback: The callback PDB proc to call.
232 *
233 * Installs a progress callback for the current plug-in.
234 *
235 * This function installs a temporary PDB procedure which will handle
236 * all progress calls made by this plug-in and any procedure it calls.
237 * Calling this function multiple times simply replaces the old
238 * progress callbacks.
239 *
240 * Returns: TRUE on success.
241 *
242 * Since: 2.2
243 **/
244 gboolean
_gimp_progress_install(const gchar * progress_callback)245 _gimp_progress_install (const gchar *progress_callback)
246 {
247 GimpParam *return_vals;
248 gint nreturn_vals;
249 gboolean success = TRUE;
250
251 return_vals = gimp_run_procedure ("gimp-progress-install",
252 &nreturn_vals,
253 GIMP_PDB_STRING, progress_callback,
254 GIMP_PDB_END);
255
256 success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
257
258 gimp_destroy_params (return_vals, nreturn_vals);
259
260 return success;
261 }
262
263 /**
264 * _gimp_progress_uninstall:
265 * @progress_callback: The name of the callback registered for this progress.
266 *
267 * Uninstalls the progress callback for the current plug-in.
268 *
269 * This function uninstalls any progress callback installed with
270 * gimp_progress_install() before.
271 *
272 * Returns: TRUE on success.
273 *
274 * Since: 2.2
275 **/
276 gboolean
_gimp_progress_uninstall(const gchar * progress_callback)277 _gimp_progress_uninstall (const gchar *progress_callback)
278 {
279 GimpParam *return_vals;
280 gint nreturn_vals;
281 gboolean success = TRUE;
282
283 return_vals = gimp_run_procedure ("gimp-progress-uninstall",
284 &nreturn_vals,
285 GIMP_PDB_STRING, progress_callback,
286 GIMP_PDB_END);
287
288 success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
289
290 gimp_destroy_params (return_vals, nreturn_vals);
291
292 return success;
293 }
294
295 /**
296 * gimp_progress_cancel:
297 * @progress_callback: The name of the callback registered for this progress.
298 *
299 * Cancels a running progress.
300 *
301 * This function cancels the currently running progress.
302 *
303 * Returns: TRUE on success.
304 *
305 * Since: 2.2
306 **/
307 gboolean
gimp_progress_cancel(const gchar * progress_callback)308 gimp_progress_cancel (const gchar *progress_callback)
309 {
310 GimpParam *return_vals;
311 gint nreturn_vals;
312 gboolean success = TRUE;
313
314 return_vals = gimp_run_procedure ("gimp-progress-cancel",
315 &nreturn_vals,
316 GIMP_PDB_STRING, progress_callback,
317 GIMP_PDB_END);
318
319 success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
320
321 gimp_destroy_params (return_vals, nreturn_vals);
322
323 return success;
324 }
325