palette-select-cmds.c 9.79 KB
Newer Older
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 3 of the License, or
7 8 9 10 11 12 13 14
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
15
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
16 17
 */

18
/* NOTE: This file is auto-generated by pdbgen.pl. */
19 20 21

#include "config.h"

22
#include <gegl.h>
23

24 25
#include <gdk-pixbuf/gdk-pixbuf.h>

26 27
#include "libgimpbase/gimpbase.h"

28 29 30 31
#include "pdb-types.h"

#include "core/gimp.h"
#include "core/gimpdatafactory.h"
32
#include "core/gimpparamspecs.h"
33

34 35
#include "gimppdb.h"
#include "gimpprocedure.h"
36
#include "internal-procs.h"
37

38

39
static GimpValueArray *
40
palettes_popup_invoker (GimpProcedure         *procedure,
41 42 43 44 45
                        Gimp                  *gimp,
                        GimpContext           *context,
                        GimpProgress          *progress,
                        const GimpValueArray  *args,
                        GError               **error)
46 47
{
  gboolean success = TRUE;
48 49 50
  const gchar *palette_callback;
  const gchar *popup_title;
  const gchar *initial_palette;
51

52 53 54
  palette_callback = g_value_get_string (gimp_value_array_index (args, 0));
  popup_title = g_value_get_string (gimp_value_array_index (args, 1));
  initial_palette = g_value_get_string (gimp_value_array_index (args, 2));
55 56 57

  if (success)
    {
58
      if (gimp->no_interface ||
59
          ! gimp_pdb_lookup_procedure (gimp->pdb, palette_callback) ||
60
          ! gimp_pdb_dialog_new (gimp, context, progress,
61
                                 gimp_data_factory_get_container (gimp->palette_factory),
62 63
                                 popup_title, palette_callback, initial_palette,
                                 NULL))
64
        success = FALSE;
65 66
    }

67 68
  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
69 70
}

71
static GimpValueArray *
72
palettes_close_popup_invoker (GimpProcedure         *procedure,
73 74 75 76 77
                              Gimp                  *gimp,
                              GimpContext           *context,
                              GimpProgress          *progress,
                              const GimpValueArray  *args,
                              GError               **error)
78 79
{
  gboolean success = TRUE;
80
  const gchar *palette_callback;
81

82
  palette_callback = g_value_get_string (gimp_value_array_index (args, 0));
83 84 85

  if (success)
    {
86
      if (gimp->no_interface ||
87
          ! gimp_pdb_lookup_procedure (gimp->pdb, palette_callback) ||
88
          ! gimp_pdb_dialog_close (gimp, gimp_data_factory_get_container (gimp->palette_factory),
89
                                   palette_callback))
90
        success = FALSE;
91 92
    }

93 94
  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
95 96
}

97
static GimpValueArray *
98
palettes_set_popup_invoker (GimpProcedure         *procedure,
99 100 101 102 103
                            Gimp                  *gimp,
                            GimpContext           *context,
                            GimpProgress          *progress,
                            const GimpValueArray  *args,
                            GError               **error)
104 105
{
  gboolean success = TRUE;
106 107
  const gchar *palette_callback;
  const gchar *palette_name;
108

109 110
  palette_callback = g_value_get_string (gimp_value_array_index (args, 0));
  palette_name = g_value_get_string (gimp_value_array_index (args, 1));
111 112 113

  if (success)
    {
114
      if (gimp->no_interface ||
115
          ! gimp_pdb_lookup_procedure (gimp->pdb, palette_callback) ||
116
          ! gimp_pdb_dialog_set (gimp, gimp_data_factory_get_container (gimp->palette_factory),
117 118
                                 palette_callback, palette_name,
                                 NULL))
119
        success = FALSE;
120 121
    }

122 123
  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
124 125
}

126
void
127
register_palette_select_procs (GimpPDB *pdb)
128
{
129 130 131 132 133
  GimpProcedure *procedure;

  /*
   * gimp-palettes-popup
   */
134
  procedure = gimp_procedure_new (palettes_popup_invoker);
135 136
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-palettes-popup");
137 138 139
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-palettes-popup",
                                     "Invokes the Gimp palette selection.",
140
                                     "This procedure opens the palette selection dialog.",
141 142 143 144 145 146 147 148
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "2002",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("palette-callback",
                                                       "palette callback",
                                                       "The callback PDB proc to call when palette selection is made",
149
                                                       FALSE, FALSE, TRUE,
150 151 152 153 154
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("popup-title",
                                                       "popup title",
155
                                                       "Title of the palette selection dialog",
156
                                                       FALSE, FALSE, FALSE,
157 158 159 160 161 162
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("initial-palette",
                                                       "initial palette",
                                                       "The name of the palette to set as the first selected",
163
                                                       FALSE, TRUE, FALSE,
164 165
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
166
  gimp_pdb_register_procedure (pdb, procedure);
167
  g_object_unref (procedure);
168 169 170 171

  /*
   * gimp-palettes-close-popup
   */
172
  procedure = gimp_procedure_new (palettes_close_popup_invoker);
173 174
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-palettes-close-popup");
175 176
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-palettes-close-popup",
177
                                     "Close the palette selection dialog.",
178 179 180 181 182 183 184 185
                                     "This procedure closes an opened palette selection dialog.",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "2002",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("palette-callback",
                                                       "palette callback",
186
                                                       "The name of the callback registered for this pop-up",
187
                                                       FALSE, FALSE, TRUE,
188 189
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
190
  gimp_pdb_register_procedure (pdb, procedure);
191
  g_object_unref (procedure);
192 193 194 195

  /*
   * gimp-palettes-set-popup
   */
196
  procedure = gimp_procedure_new (palettes_set_popup_invoker);
197 198
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-palettes-set-popup");
199 200
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-palettes-set-popup",
201 202
                                     "Sets the current palette in a palette selection dialog.",
                                     "Sets the current palette in a palette selection dialog.",
203 204 205 206 207 208 209
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "2002",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("palette-callback",
                                                       "palette callback",
210
                                                       "The name of the callback registered for this pop-up",
211
                                                       FALSE, FALSE, TRUE,
212 213 214 215 216 217
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("palette-name",
                                                       "palette name",
                                                       "The name of the palette to set as selected",
218
                                                       FALSE, FALSE, FALSE,
219 220
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
221
  gimp_pdb_register_procedure (pdb, procedure);
222
  g_object_unref (procedure);
223
}