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

« back to all changes in this revision

Viewing changes to app/widgets/gimppdbdialog.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* The GIMP -- an image manipulation program
 
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * gimppdbdialog.c
29
29
 
30
30
#include "widgets-types.h"
31
31
 
 
32
#include "core/gimp.h"
32
33
#include "core/gimpcontext.h"
33
34
 
34
 
#include "pdb/procedural_db.h"
 
35
#include "pdb/gimppdb.h"
35
36
 
36
37
#include "gimpmenufactory.h"
37
38
#include "gimppdbdialog.h"
 
39
#include "gimpwidgets-utils.h"
38
40
 
39
41
#include "gimp-intl.h"
40
42
 
42
44
enum
43
45
{
44
46
  PROP_0,
 
47
  PROP_PDB,
45
48
  PROP_CONTEXT,
46
49
  PROP_SELECT_TYPE,
47
50
  PROP_INITIAL_OBJECT,
71
74
static void     gimp_pdb_dialog_context_changed (GimpContext        *context,
72
75
                                                 GimpObject         *object,
73
76
                                                 GimpPdbDialog      *dialog);
 
77
static void     gimp_pdb_dialog_plug_in_closed  (GimpPlugInManager  *manager,
 
78
                                                 GimpPlugIn         *plug_in,
 
79
                                                 GimpPdbDialog      *dialog);
74
80
 
75
81
 
76
82
static GimpDialogClass *parent_class = NULL;
83
89
 
84
90
  if (! dialog_type)
85
91
    {
86
 
      static const GTypeInfo dialog_info =
 
92
      const GTypeInfo dialog_info =
87
93
      {
88
94
        sizeof (GimpPdbDialogClass),
89
95
        (GBaseInitFunc) NULL,
128
134
  g_object_class_install_property (object_class, PROP_CONTEXT,
129
135
                                   g_param_spec_object ("context", NULL, NULL,
130
136
                                                        GIMP_TYPE_CONTEXT,
131
 
                                                        G_PARAM_WRITABLE |
 
137
                                                        GIMP_PARAM_WRITABLE |
 
138
                                                        G_PARAM_CONSTRUCT_ONLY));
 
139
 
 
140
  g_object_class_install_property (object_class, PROP_PDB,
 
141
                                   g_param_spec_object ("pdb", NULL, NULL,
 
142
                                                        GIMP_TYPE_PDB,
 
143
                                                        GIMP_PARAM_WRITABLE |
132
144
                                                        G_PARAM_CONSTRUCT_ONLY));
133
145
 
134
146
  g_object_class_install_property (object_class, PROP_SELECT_TYPE,
135
 
                                   g_param_spec_pointer ("select-type",
136
 
                                                         NULL, NULL,
137
 
                                                         G_PARAM_WRITABLE |
138
 
                                                         G_PARAM_CONSTRUCT_ONLY));
 
147
                                   g_param_spec_gtype ("select-type",
 
148
                                                       NULL, NULL,
 
149
                                                       GIMP_TYPE_OBJECT,
 
150
                                                       GIMP_PARAM_WRITABLE |
 
151
                                                       G_PARAM_CONSTRUCT_ONLY));
139
152
 
140
153
  g_object_class_install_property (object_class, PROP_INITIAL_OBJECT,
141
154
                                   g_param_spec_object ("initial-object",
142
155
                                                        NULL, NULL,
143
156
                                                        GIMP_TYPE_OBJECT,
144
 
                                                        G_PARAM_WRITABLE |
 
157
                                                        GIMP_PARAM_WRITABLE |
145
158
                                                        G_PARAM_CONSTRUCT_ONLY));
146
159
 
147
160
  g_object_class_install_property (object_class, PROP_CALLBACK_NAME,
148
161
                                   g_param_spec_string ("callback-name",
149
162
                                                        NULL, NULL,
150
163
                                                        NULL,
151
 
                                                        G_PARAM_WRITABLE |
 
164
                                                        GIMP_PARAM_WRITABLE |
152
165
                                                        G_PARAM_CONSTRUCT_ONLY));
153
166
 
154
167
  g_object_class_install_property (object_class, PROP_MENU_FACTORY,
155
168
                                   g_param_spec_object ("menu-factory",
156
169
                                                        NULL, NULL,
157
170
                                                        GIMP_TYPE_MENU_FACTORY,
158
 
                                                        G_PARAM_WRITABLE |
 
171
                                                        GIMP_PARAM_WRITABLE |
159
172
                                                        G_PARAM_CONSTRUCT_ONLY));
160
173
}
161
174
 
182
195
 
183
196
  dialog = GIMP_PDB_DIALOG (object);
184
197
 
 
198
  g_assert (GIMP_IS_PDB (dialog->pdb));
185
199
  g_assert (GIMP_IS_CONTEXT (dialog->caller_context));
186
200
  g_assert (g_type_is_a (dialog->select_type, GIMP_TYPE_OBJECT));
187
201
 
199
213
  g_signal_connect_object (dialog->context, signal_name,
200
214
                           G_CALLBACK (gimp_pdb_dialog_context_changed),
201
215
                           dialog, 0);
 
216
  g_signal_connect_object (dialog->context->gimp->plug_in_manager,
 
217
                           "plug-in-closed",
 
218
                           G_CALLBACK (gimp_pdb_dialog_plug_in_closed),
 
219
                           dialog, 0);
202
220
 
203
221
  return object;
204
222
}
223
241
 
224
242
  switch (property_id)
225
243
    {
 
244
    case PROP_PDB:
 
245
      dialog->pdb = GIMP_PDB (g_value_dup_object (value));
 
246
      break;
226
247
    case PROP_CONTEXT:
227
248
      dialog->caller_context = GIMP_CONTEXT (g_value_dup_object (value));
228
249
      break;
229
250
    case PROP_SELECT_TYPE:
230
 
      dialog->select_type = (GType) g_value_get_pointer (value);
 
251
      dialog->select_type = g_value_get_gtype (value);
231
252
      break;
232
253
    case PROP_INITIAL_OBJECT:
233
254
      /* don't ref, see constructor */
252
273
{
253
274
  GimpPdbDialog *dialog = GIMP_PDB_DIALOG (object);
254
275
 
 
276
  if (dialog->pdb)
 
277
    {
 
278
      g_object_unref (dialog->pdb);
 
279
      dialog->pdb = NULL;
 
280
    }
 
281
 
255
282
  if (dialog->caller_context)
256
283
    {
257
284
      g_object_unref (dialog->caller_context);
305
332
    {
306
333
      dialog->callback_busy = TRUE;
307
334
 
308
 
      if (procedural_db_lookup (dialog->caller_context->gimp,
309
 
                                dialog->callback_name))
 
335
      if (gimp_pdb_lookup_procedure (dialog->pdb, dialog->callback_name))
310
336
        {
311
 
          Argument *return_vals;
312
 
          gint      n_return_vals;
313
 
 
314
 
          return_vals = klass->run_callback (dialog, object, closing,
315
 
                                             &n_return_vals);
316
 
 
317
 
          if (! return_vals ||
318
 
              return_vals[0].value.pdb_int != GIMP_PDB_SUCCESS)
 
337
          GValueArray *return_vals;
 
338
 
 
339
          return_vals = klass->run_callback (dialog, object, closing);
 
340
 
 
341
          if (g_value_get_enum (&return_vals->values[0]) != GIMP_PDB_SUCCESS)
319
342
            {
320
 
              g_message (_("Unable to run %s callback. "
321
 
                           "The corresponding plug-in may have crashed."),
322
 
                         g_type_name (G_TYPE_FROM_INSTANCE (dialog)));
 
343
              gimp_message (dialog->context->gimp, G_OBJECT (dialog),
 
344
                            GIMP_MESSAGE_ERROR,
 
345
                            _("Unable to run %s callback. "
 
346
                              "The corresponding plug-in may have "
 
347
                              "crashed."),
 
348
                            g_type_name (G_TYPE_FROM_INSTANCE (dialog)));
323
349
            }
324
350
 
325
 
          if (return_vals)
326
 
            procedural_db_destroy_args (return_vals, n_return_vals);
 
351
          g_value_array_free (return_vals);
327
352
        }
328
353
 
329
354
      dialog->callback_busy = FALSE;
345
370
 
346
371
      if (dialog->callback_name &&
347
372
          ! strcmp (callback_name, dialog->callback_name))
348
 
        return dialog;
 
373
        return dialog;
349
374
    }
350
375
 
351
376
  return NULL;
352
377
}
353
378
 
354
 
void
355
 
gimp_pdb_dialogs_check_callback (GimpPdbDialogClass *klass)
356
 
{
357
 
  GList *list;
358
 
 
359
 
  g_return_if_fail (GIMP_IS_PDB_DIALOG_CLASS (klass));
360
 
 
361
 
  list = klass->dialogs;
362
 
 
363
 
  while (list)
364
 
    {
365
 
      GimpPdbDialog *dialog = list->data;
366
 
 
367
 
      list = g_list_next (list);
368
 
 
369
 
      if (dialog->caller_context && dialog->callback_name)
370
 
        {
371
 
          if (! procedural_db_lookup (dialog->caller_context->gimp,
372
 
                                      dialog->callback_name))
373
 
            {
374
 
              gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
375
 
            }
376
 
        }
377
 
    }
378
 
}
379
 
 
380
379
 
381
380
/*  private functions  */
382
381
 
388
387
  if (object)
389
388
    gimp_pdb_dialog_run_callback (dialog, FALSE);
390
389
}
 
390
 
 
391
static void
 
392
gimp_pdb_dialog_plug_in_closed (GimpPlugInManager *manager,
 
393
                                GimpPlugIn        *plug_in,
 
394
                                GimpPdbDialog     *dialog)
 
395
{
 
396
  if (dialog->caller_context && dialog->callback_name)
 
397
    {
 
398
      if (! gimp_pdb_lookup_procedure (dialog->pdb, dialog->callback_name))
 
399
        {
 
400
          gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
 
401
        }
 
402
    }
 
403
}