~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/pdb/display_cmds.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2008-10-06 13:30:41 UTC
  • mto: This revision was merged to the branch mainline in revision 35.
  • Revision ID: james.westby@ubuntu.com-20081006133041-3panbkcanaymfsmp
Tags: upstream-2.6.0
ImportĀ upstreamĀ versionĀ 2.6.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* GIMP - The GNU Image Manipulation Program
2
 
 * Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
3
 
 *
4
 
 * This program is free software; you can redistribute it and/or modify
5
 
 * it under the terms of the GNU General Public License as published by
6
 
 * the Free Software Foundation; either version 2 of the License, or
7
 
 * (at your option) any later version.
8
 
 *
9
 
 * This program is distributed in the hope that it will be useful,
10
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
 * GNU General Public License for more details.
13
 
 *
14
 
 * You should have received a copy of the GNU General Public License
15
 
 * along with this program; if not, write to the Free Software
16
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
 
 */
18
 
 
19
 
/* NOTE: This file is auto-generated by pdbgen.pl. */
20
 
 
21
 
#include "config.h"
22
 
 
23
 
 
24
 
#include <glib-object.h>
25
 
 
26
 
#include "pdb-types.h"
27
 
#include "gimppdb.h"
28
 
#include "gimpprocedure.h"
29
 
#include "core/gimpparamspecs.h"
30
 
 
31
 
#include "core/gimp.h"
32
 
#include "core/gimpcontainer.h"
33
 
#include "core/gimpimage.h"
34
 
 
35
 
#include "internal_procs.h"
36
 
 
37
 
 
38
 
static GValueArray *
39
 
display_is_valid_invoker (GimpProcedure     *procedure,
40
 
                          Gimp              *gimp,
41
 
                          GimpContext       *context,
42
 
                          GimpProgress      *progress,
43
 
                          const GValueArray *args)
44
 
{
45
 
  GValueArray *return_vals;
46
 
  GimpObject *display;
47
 
  gboolean valid = FALSE;
48
 
 
49
 
  display = gimp_value_get_display (&args->values[0], gimp);
50
 
 
51
 
  valid = (display != NULL);
52
 
 
53
 
  return_vals = gimp_procedure_get_return_values (procedure, TRUE);
54
 
  g_value_set_boolean (&return_vals->values[1], valid);
55
 
 
56
 
  return return_vals;
57
 
}
58
 
 
59
 
static GValueArray *
60
 
display_new_invoker (GimpProcedure     *procedure,
61
 
                     Gimp              *gimp,
62
 
                     GimpContext       *context,
63
 
                     GimpProgress      *progress,
64
 
                     const GValueArray *args)
65
 
{
66
 
  gboolean success = TRUE;
67
 
  GValueArray *return_vals;
68
 
  GimpImage *image;
69
 
  GimpObject *display = NULL;
70
 
 
71
 
  image = gimp_value_get_image (&args->values[0], gimp);
72
 
 
73
 
  if (success)
74
 
    {
75
 
      gimp_image_flush (image);
76
 
 
77
 
      display = gimp_create_display (gimp, image, GIMP_UNIT_PIXEL, 1.0);
78
 
 
79
 
      if (display)
80
 
        {
81
 
          /* the first display takes ownership of the image */
82
 
          if (image->disp_count == 1)
83
 
            g_object_unref (image);
84
 
        }
85
 
      else
86
 
        success = FALSE;
87
 
    }
88
 
 
89
 
  return_vals = gimp_procedure_get_return_values (procedure, success);
90
 
 
91
 
  if (success)
92
 
    gimp_value_set_display (&return_vals->values[1], display);
93
 
 
94
 
  return return_vals;
95
 
}
96
 
 
97
 
static GValueArray *
98
 
display_delete_invoker (GimpProcedure     *procedure,
99
 
                        Gimp              *gimp,
100
 
                        GimpContext       *context,
101
 
                        GimpProgress      *progress,
102
 
                        const GValueArray *args)
103
 
{
104
 
  gboolean success = TRUE;
105
 
  GimpObject *display;
106
 
 
107
 
  display = gimp_value_get_display (&args->values[0], gimp);
108
 
 
109
 
  if (success)
110
 
    {
111
 
      gimp_delete_display (gimp, display);
112
 
    }
113
 
 
114
 
  return gimp_procedure_get_return_values (procedure, success);
115
 
}
116
 
 
117
 
static GValueArray *
118
 
display_get_window_handle_invoker (GimpProcedure     *procedure,
119
 
                                   Gimp              *gimp,
120
 
                                   GimpContext       *context,
121
 
                                   GimpProgress      *progress,
122
 
                                   const GValueArray *args)
123
 
{
124
 
  gboolean success = TRUE;
125
 
  GValueArray *return_vals;
126
 
  GimpObject *display;
127
 
  gint32 window = 0;
128
 
 
129
 
  display = gimp_value_get_display (&args->values[0], gimp);
130
 
 
131
 
  if (success)
132
 
    {
133
 
      window = (gint32) gimp_get_display_window (gimp, display);
134
 
    }
135
 
 
136
 
  return_vals = gimp_procedure_get_return_values (procedure, success);
137
 
 
138
 
  if (success)
139
 
    g_value_set_int (&return_vals->values[1], window);
140
 
 
141
 
  return return_vals;
142
 
}
143
 
 
144
 
static GValueArray *
145
 
displays_flush_invoker (GimpProcedure     *procedure,
146
 
                        Gimp              *gimp,
147
 
                        GimpContext       *context,
148
 
                        GimpProgress      *progress,
149
 
                        const GValueArray *args)
150
 
{
151
 
  gimp_container_foreach (gimp->images, (GFunc) gimp_image_flush, NULL);
152
 
  return gimp_procedure_get_return_values (procedure, TRUE);
153
 
}
154
 
 
155
 
static GValueArray *
156
 
displays_reconnect_invoker (GimpProcedure     *procedure,
157
 
                            Gimp              *gimp,
158
 
                            GimpContext       *context,
159
 
                            GimpProgress      *progress,
160
 
                            const GValueArray *args)
161
 
{
162
 
  gboolean success = TRUE;
163
 
  GimpImage *old_image;
164
 
  GimpImage *new_image;
165
 
 
166
 
  old_image = gimp_value_get_image (&args->values[0], gimp);
167
 
  new_image = gimp_value_get_image (&args->values[1], gimp);
168
 
 
169
 
  if (success)
170
 
    {
171
 
      success = (old_image != new_image    &&
172
 
                 old_image->disp_count > 0 &&
173
 
                 new_image->disp_count == 0);
174
 
 
175
 
      if (success)
176
 
        {
177
 
          gimp_reconnect_displays (gimp, old_image, new_image);
178
 
 
179
 
          /* take ownership of the image */
180
 
          if (new_image->disp_count > 0)
181
 
            g_object_unref (new_image);
182
 
        }
183
 
    }
184
 
 
185
 
  return gimp_procedure_get_return_values (procedure, success);
186
 
}
187
 
 
188
 
void
189
 
register_display_procs (GimpPDB *pdb)
190
 
{
191
 
  GimpProcedure *procedure;
192
 
 
193
 
  /*
194
 
   * gimp-display-is-valid
195
 
   */
196
 
  procedure = gimp_procedure_new (display_is_valid_invoker);
197
 
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-display-is-valid");
198
 
  gimp_procedure_set_static_strings (procedure,
199
 
                                     "gimp-display-is-valid",
200
 
                                     "Returns TRUE if the display is valid.",
201
 
                                     "This procedure checks if the given display ID is valid and refers to an existing display.",
202
 
                                     "Sven Neumann <sven@gimp.org>",
203
 
                                     "Sven Neumann",
204
 
                                     "2007",
205
 
                                     NULL);
206
 
  gimp_procedure_add_argument (procedure,
207
 
                               gimp_param_spec_display_id ("display",
208
 
                                                           "display",
209
 
                                                           "The display to check",
210
 
                                                           pdb->gimp, FALSE,
211
 
                                                           GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
212
 
  gimp_procedure_add_return_value (procedure,
213
 
                                   g_param_spec_boolean ("valid",
214
 
                                                         "valid",
215
 
                                                         "Whether the display ID is valid",
216
 
                                                         FALSE,
217
 
                                                         GIMP_PARAM_READWRITE));
218
 
  gimp_pdb_register_procedure (pdb, procedure);
219
 
  g_object_unref (procedure);
220
 
 
221
 
  /*
222
 
   * gimp-display-new
223
 
   */
224
 
  procedure = gimp_procedure_new (display_new_invoker);
225
 
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-display-new");
226
 
  gimp_procedure_set_static_strings (procedure,
227
 
                                     "gimp-display-new",
228
 
                                     "Create a new display for the specified image.",
229
 
                                     "Creates a new display for the specified image. If the image already has a display, another is added. Multiple displays are handled transparently by GIMP. The newly created display is returned and can be subsequently destroyed with a call to 'gimp-display-delete'. This procedure only makes sense for use with the GIMP UI.",
230
 
                                     "Spencer Kimball & Peter Mattis",
231
 
                                     "Spencer Kimball & Peter Mattis",
232
 
                                     "1995-1996",
233
 
                                     NULL);
234
 
  gimp_procedure_add_argument (procedure,
235
 
                               gimp_param_spec_image_id ("image",
236
 
                                                         "image",
237
 
                                                         "The image",
238
 
                                                         pdb->gimp, FALSE,
239
 
                                                         GIMP_PARAM_READWRITE));
240
 
  gimp_procedure_add_return_value (procedure,
241
 
                                   gimp_param_spec_display_id ("display",
242
 
                                                               "display",
243
 
                                                               "The new display",
244
 
                                                               pdb->gimp, FALSE,
245
 
                                                               GIMP_PARAM_READWRITE));
246
 
  gimp_pdb_register_procedure (pdb, procedure);
247
 
  g_object_unref (procedure);
248
 
 
249
 
  /*
250
 
   * gimp-display-delete
251
 
   */
252
 
  procedure = gimp_procedure_new (display_delete_invoker);
253
 
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-display-delete");
254
 
  gimp_procedure_set_static_strings (procedure,
255
 
                                     "gimp-display-delete",
256
 
                                     "Delete the specified display.",
257
 
                                     "This procedure removes the specified display. If this is the last remaining display for the underlying image, then the image is deleted also. Note that the display is closed no matter if the image is dirty or not. Better save the image before calling this procedure.",
258
 
                                     "Spencer Kimball & Peter Mattis",
259
 
                                     "Spencer Kimball & Peter Mattis",
260
 
                                     "1995-1996",
261
 
                                     NULL);
262
 
  gimp_procedure_add_argument (procedure,
263
 
                               gimp_param_spec_display_id ("display",
264
 
                                                           "display",
265
 
                                                           "The display to delete",
266
 
                                                           pdb->gimp, FALSE,
267
 
                                                           GIMP_PARAM_READWRITE));
268
 
  gimp_pdb_register_procedure (pdb, procedure);
269
 
  g_object_unref (procedure);
270
 
 
271
 
  /*
272
 
   * gimp-display-get-window-handle
273
 
   */
274
 
  procedure = gimp_procedure_new (display_get_window_handle_invoker);
275
 
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-display-get-window-handle");
276
 
  gimp_procedure_set_static_strings (procedure,
277
 
                                     "gimp-display-get-window-handle",
278
 
                                     "Get a handle to the native window for an image display.",
279
 
                                     "This procedure returns a handle to the native window for a given image display. For example in the X backend of GDK, a native window handle is an Xlib XID. A value of 0 is returned for an invalid display or if this function is unimplemented for the windowing system that is being used.",
280
 
                                     "Sven Neumann <sven@gimp.org>",
281
 
                                     "Sven Neumann",
282
 
                                     "2005",
283
 
                                     NULL);
284
 
  gimp_procedure_add_argument (procedure,
285
 
                               gimp_param_spec_display_id ("display",
286
 
                                                           "display",
287
 
                                                           "The display to get the window handle from",
288
 
                                                           pdb->gimp, FALSE,
289
 
                                                           GIMP_PARAM_READWRITE));
290
 
  gimp_procedure_add_return_value (procedure,
291
 
                                   gimp_param_spec_int32 ("window",
292
 
                                                          "window",
293
 
                                                          "The native window handle or 0",
294
 
                                                          G_MININT32, G_MAXINT32, 0,
295
 
                                                          GIMP_PARAM_READWRITE));
296
 
  gimp_pdb_register_procedure (pdb, procedure);
297
 
  g_object_unref (procedure);
298
 
 
299
 
  /*
300
 
   * gimp-displays-flush
301
 
   */
302
 
  procedure = gimp_procedure_new (displays_flush_invoker);
303
 
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-displays-flush");
304
 
  gimp_procedure_set_static_strings (procedure,
305
 
                                     "gimp-displays-flush",
306
 
                                     "Flush all internal changes to the user interface",
307
 
                                     "This procedure takes no arguments and returns nothing except a success status. Its purpose is to flush all pending updates of image manipulations to the user interface. It should be called whenever appropriate.",
308
 
                                     "Spencer Kimball & Peter Mattis",
309
 
                                     "Spencer Kimball & Peter Mattis",
310
 
                                     "1995-1996",
311
 
                                     NULL);
312
 
  gimp_pdb_register_procedure (pdb, procedure);
313
 
  g_object_unref (procedure);
314
 
 
315
 
  /*
316
 
   * gimp-displays-reconnect
317
 
   */
318
 
  procedure = gimp_procedure_new (displays_reconnect_invoker);
319
 
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-displays-reconnect");
320
 
  gimp_procedure_set_static_strings (procedure,
321
 
                                     "gimp-displays-reconnect",
322
 
                                     "Reconnect displays from one image to another image.",
323
 
                                     "This procedure connects all displays of the old_image to the new_image. If the old_image has no display or new_image already has a display the reconnect is not performed and the procedure returns without success. You should rarely need to use this function.",
324
 
                                     "Spencer Kimball & Peter Mattis",
325
 
                                     "Spencer Kimball & Peter Mattis",
326
 
                                     "1995-1996",
327
 
                                     NULL);
328
 
  gimp_procedure_add_argument (procedure,
329
 
                               gimp_param_spec_image_id ("old-image",
330
 
                                                         "old image",
331
 
                                                         "The old image (must have at least one display)",
332
 
                                                         pdb->gimp, FALSE,
333
 
                                                         GIMP_PARAM_READWRITE));
334
 
  gimp_procedure_add_argument (procedure,
335
 
                               gimp_param_spec_image_id ("new-image",
336
 
                                                         "new image",
337
 
                                                         "The new image (must not have a display)",
338
 
                                                         pdb->gimp, FALSE,
339
 
                                                         GIMP_PARAM_READWRITE));
340
 
  gimp_pdb_register_procedure (pdb, procedure);
341
 
  g_object_unref (procedure);
342
 
}