gimpdisplay_pdb.c 7.77 KB
Newer Older
1
/* LIBGIMP - The GIMP Library
2
 * Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
3 4
 *
 * gimpdisplay_pdb.c
Manish Singh's avatar
Manish Singh committed
5
 *
6
 * This library is free software: you can redistribute it and/or
Marc Lehmann's avatar
Marc Lehmann committed
7
 * modify it under the terms of the GNU Lesser General Public
Manish Singh's avatar
Manish Singh committed
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 12 13
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 * Lesser General Public License for more details.
Manish Singh's avatar
Manish Singh committed
15
 *
Marc Lehmann's avatar
Marc Lehmann committed
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 */
Elliot Lee's avatar
Elliot Lee committed
22

Sven Neumann's avatar
Sven Neumann committed
23 24
#include "config.h"

25
#include "gimp.h"
Elliot Lee's avatar
Elliot Lee committed
26

27 28

/**
29
 * SECTION: gimpdisplay
30 31 32 33 34 35 36
 * @title: gimpdisplay
 * @short_description: Functions to create, delete and flush displays (views) on an image.
 *
 * Functions to create, delete and flush displays (views) on an image.
 **/


37
/**
38 39
 * gimp_display_id_is_valid:
 * @display_id: The display ID to check.
40
 *
41
 * Returns TRUE if the display ID is valid.
42 43 44 45 46 47
 *
 * This procedure checks if the given display ID is valid and refers to
 * an existing display.
 *
 * Returns: Whether the display ID is valid.
 *
48
 * Since: 3.0
49
 **/
50
gboolean
51
gimp_display_id_is_valid (gint display_id)
52
{
53 54
  GimpValueArray *args;
  GimpValueArray *return_vals;
55 56
  gboolean valid = FALSE;

57
  args = gimp_value_array_new_from_types (NULL,
58
                                          G_TYPE_INT, display_id,
59
                                          G_TYPE_NONE);
60

61 62 63
  return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
                                              "gimp-display-id-is-valid",
                                              args);
64
  gimp_value_array_unref (args);
65

66
  if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
67
    valid = GIMP_VALUES_GET_BOOLEAN (return_vals, 1);
68 69

  gimp_value_array_unref (return_vals);
70 71 72 73

  return valid;
}

74 75
/**
 * gimp_display_new:
76
 * @image: The image.
77 78 79 80 81
 *
 * Create a new display for the specified image.
 *
 * Creates a new display for the specified image. If the image already
 * has a display, another is added. Multiple displays are handled
82 83
 * transparently by GIMP. The newly created display is returned and can
 * be subsequently destroyed with a call to gimp_display_delete(). This
84 85
 * procedure only makes sense for use with the GIMP UI, and will result
 * in an execution error if called when GIMP has no UI.
86
 *
87
 * Returns: (transfer none): The new display.
88
 **/
89
GimpDisplay *
90
gimp_display_new (GimpImage *image)
Elliot Lee's avatar
Elliot Lee committed
91
{
92 93
  GimpValueArray *args;
  GimpValueArray *return_vals;
94
  GimpDisplay *display = NULL;
Elliot Lee's avatar
Elliot Lee committed
95

96
  args = gimp_value_array_new_from_types (NULL,
97
                                          GIMP_TYPE_IMAGE, image,
98 99
                                          G_TYPE_NONE);

100 101 102
  return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
                                              "gimp-display-new",
                                              args);
103
  gimp_value_array_unref (args);
Elliot Lee's avatar
Elliot Lee committed
104

105
  if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
106
    display = GIMP_VALUES_GET_DISPLAY (return_vals, 1);
Elliot Lee's avatar
Elliot Lee committed
107

108
  gimp_value_array_unref (return_vals);
Elliot Lee's avatar
Elliot Lee committed
109

110
  return display;
Elliot Lee's avatar
Elliot Lee committed
111 112
}

113 114
/**
 * gimp_display_delete:
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
 * @display: The display to delete.
 *
 * Delete the specified display.
 *
 * 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.
 *
 * Returns: TRUE on success.
 **/
gboolean
gimp_display_delete (GimpDisplay *display)
{
  GimpValueArray *args;
  GimpValueArray *return_vals;
  gboolean success = TRUE;

  args = gimp_value_array_new_from_types (NULL,
135
                                          GIMP_TYPE_DISPLAY, display,
136 137
                                          G_TYPE_NONE);

138 139 140
  return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
                                              "gimp-display-delete",
                                              args);
141 142
  gimp_value_array_unref (args);

143
  success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
144 145 146 147 148 149

  gimp_value_array_unref (return_vals);

  return success;
}

Sven Neumann's avatar
Sven Neumann committed
150 151
/**
 * gimp_display_get_window_handle:
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
 * @display: The display to get the window handle from.
 *
 * Get a handle to the native window for an image display.
 *
 * 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.
 *
 * Returns: The native window handle or 0.
 *
 * Since: 2.4
 **/
gint
gimp_display_get_window_handle (GimpDisplay *display)
{
  GimpValueArray *args;
  GimpValueArray *return_vals;
  gint window = 0;

  args = gimp_value_array_new_from_types (NULL,
174
                                          GIMP_TYPE_DISPLAY, display,
175 176
                                          G_TYPE_NONE);

177 178 179
  return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
                                              "gimp-display-get-window-handle",
                                              args);
180 181
  gimp_value_array_unref (args);

182
  if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
183
    window = GIMP_VALUES_GET_INT (return_vals, 1);
184 185 186 187 188 189

  gimp_value_array_unref (return_vals);

  return window;
}

190 191 192 193 194 195 196 197 198 199 200
/**
 * gimp_displays_flush:
 *
 * Flush all internal changes to the user interface
 *
 * 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.
 *
 * Returns: TRUE on success.
201
 **/
202
gboolean
203
gimp_displays_flush (void)
Elliot Lee's avatar
Elliot Lee committed
204
{
205 206
  GimpValueArray *args;
  GimpValueArray *return_vals;
207
  gboolean success = TRUE;
Elliot Lee's avatar
Elliot Lee committed
208

209 210
  args = gimp_value_array_new_from_types (NULL,
                                          G_TYPE_NONE);
211

212 213 214
  return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
                                              "gimp-displays-flush",
                                              args);
215
  gimp_value_array_unref (args);
Elliot Lee's avatar
Elliot Lee committed
216

217
  success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
218

219
  gimp_value_array_unref (return_vals);
220 221

  return success;
Elliot Lee's avatar
Elliot Lee committed
222
}
223 224 225

/**
 * gimp_displays_reconnect:
226 227
 * @old_image: The old image (must have at least one display).
 * @new_image: The new image (must not have a display).
228 229 230 231
 *
 * Reconnect displays from one image to another image.
 *
 * This procedure connects all displays of the old_image to the
232 233 234
 * 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.
235 236
 *
 * Returns: TRUE on success.
237
 **/
238
gboolean
239 240
gimp_displays_reconnect (GimpImage *old_image,
                         GimpImage *new_image)
241
{
242 243
  GimpValueArray *args;
  GimpValueArray *return_vals;
244 245
  gboolean success = TRUE;

246
  args = gimp_value_array_new_from_types (NULL,
247 248
                                          GIMP_TYPE_IMAGE, old_image,
                                          GIMP_TYPE_IMAGE, new_image,
249 250
                                          G_TYPE_NONE);

251 252 253
  return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
                                              "gimp-displays-reconnect",
                                              args);
254
  gimp_value_array_unref (args);
255

256
  success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
257

258
  gimp_value_array_unref (return_vals);
259 260 261

  return success;
}