30
30
#include "widgets-types.h"
32
#include "core/gimp.h"
32
33
#include "core/gimpcontext.h"
34
#include "pdb/procedural_db.h"
35
#include "pdb/gimppdb.h"
36
37
#include "gimpmenufactory.h"
37
38
#include "gimppdbdialog.h"
39
#include "gimpwidgets-utils.h"
39
41
#include "gimp-intl.h"
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,
137
GIMP_PARAM_WRITABLE |
138
G_PARAM_CONSTRUCT_ONLY));
140
g_object_class_install_property (object_class, PROP_PDB,
141
g_param_spec_object ("pdb", NULL, NULL,
143
GIMP_PARAM_WRITABLE |
132
144
G_PARAM_CONSTRUCT_ONLY));
134
146
g_object_class_install_property (object_class, PROP_SELECT_TYPE,
135
g_param_spec_pointer ("select-type",
138
G_PARAM_CONSTRUCT_ONLY));
147
g_param_spec_gtype ("select-type",
150
GIMP_PARAM_WRITABLE |
151
G_PARAM_CONSTRUCT_ONLY));
140
153
g_object_class_install_property (object_class, PROP_INITIAL_OBJECT,
141
154
g_param_spec_object ("initial-object",
143
156
GIMP_TYPE_OBJECT,
157
GIMP_PARAM_WRITABLE |
145
158
G_PARAM_CONSTRUCT_ONLY));
147
160
g_object_class_install_property (object_class, PROP_CALLBACK_NAME,
148
161
g_param_spec_string ("callback-name",
164
GIMP_PARAM_WRITABLE |
152
165
G_PARAM_CONSTRUCT_ONLY));
154
167
g_object_class_install_property (object_class, PROP_MENU_FACTORY,
155
168
g_param_spec_object ("menu-factory",
157
170
GIMP_TYPE_MENU_FACTORY,
171
GIMP_PARAM_WRITABLE |
159
172
G_PARAM_CONSTRUCT_ONLY));
183
196
dialog = GIMP_PDB_DIALOG (object);
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));
199
213
g_signal_connect_object (dialog->context, signal_name,
200
214
G_CALLBACK (gimp_pdb_dialog_context_changed),
216
g_signal_connect_object (dialog->context->gimp->plug_in_manager,
218
G_CALLBACK (gimp_pdb_dialog_plug_in_closed),
224
242
switch (property_id)
245
dialog->pdb = GIMP_PDB (g_value_dup_object (value));
226
247
case PROP_CONTEXT:
227
248
dialog->caller_context = GIMP_CONTEXT (g_value_dup_object (value));
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);
232
253
case PROP_INITIAL_OBJECT:
233
254
/* don't ref, see constructor */
306
333
dialog->callback_busy = TRUE;
308
if (procedural_db_lookup (dialog->caller_context->gimp,
309
dialog->callback_name))
335
if (gimp_pdb_lookup_procedure (dialog->pdb, dialog->callback_name))
311
Argument *return_vals;
314
return_vals = klass->run_callback (dialog, object, closing,
318
return_vals[0].value.pdb_int != GIMP_PDB_SUCCESS)
337
GValueArray *return_vals;
339
return_vals = klass->run_callback (dialog, object, closing);
341
if (g_value_get_enum (&return_vals->values[0]) != GIMP_PDB_SUCCESS)
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),
345
_("Unable to run %s callback. "
346
"The corresponding plug-in may have "
348
g_type_name (G_TYPE_FROM_INSTANCE (dialog)));
326
procedural_db_destroy_args (return_vals, n_return_vals);
351
g_value_array_free (return_vals);
329
354
dialog->callback_busy = FALSE;
346
371
if (dialog->callback_name &&
347
372
! strcmp (callback_name, dialog->callback_name))
355
gimp_pdb_dialogs_check_callback (GimpPdbDialogClass *klass)
359
g_return_if_fail (GIMP_IS_PDB_DIALOG_CLASS (klass));
361
list = klass->dialogs;
365
GimpPdbDialog *dialog = list->data;
367
list = g_list_next (list);
369
if (dialog->caller_context && dialog->callback_name)
371
if (! procedural_db_lookup (dialog->caller_context->gimp,
372
dialog->callback_name))
374
gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
381
380
/* private functions */
389
388
gimp_pdb_dialog_run_callback (dialog, FALSE);
392
gimp_pdb_dialog_plug_in_closed (GimpPlugInManager *manager,
394
GimpPdbDialog *dialog)
396
if (dialog->caller_context && dialog->callback_name)
398
if (! gimp_pdb_lookup_procedure (dialog->pdb, dialog->callback_name))
400
gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);