mirror of https://github.com/GNOME/gimp.git
app/file/file-open.c app/file/file-save.c use procedural_db_run_proc()
2006-03-27 Michael Natterer <mitch@gimp.org> * app/file/file-open.c * app/file/file-save.c * app/plug-in/plug-ins.c: use procedural_db_run_proc() instead of procedural_db_execute(). execute() should be avoided for anything but PDB-internal calls.
This commit is contained in:
parent
df7eee5207
commit
f313c6b577
|
@ -1,3 +1,11 @@
|
|||
2006-03-27 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/file/file-open.c
|
||||
* app/file/file-save.c
|
||||
* app/plug-in/plug-ins.c: use procedural_db_run_proc() instead of
|
||||
procedural_db_execute(). execute() should be avoided for anything
|
||||
but PDB-internal calls.
|
||||
|
||||
2006-03-27 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/pdb/procedural_db.c (procedural_db_run_proc): some fixes and
|
||||
|
|
|
@ -85,11 +85,10 @@ file_open_image (Gimp *gimp,
|
|||
GError **error)
|
||||
{
|
||||
const ProcRecord *proc;
|
||||
Argument *args;
|
||||
Argument *return_vals;
|
||||
gint image_id;
|
||||
gint i;
|
||||
gint n_return_vals;
|
||||
gchar *filename;
|
||||
gint image_id;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
||||
|
@ -133,29 +132,27 @@ file_open_image (Gimp *gimp,
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
filename = g_strdup (uri);
|
||||
}
|
||||
|
||||
proc = plug_in_proc_def_get_proc (file_proc);
|
||||
|
||||
args = g_new0 (Argument, proc->num_args);
|
||||
return_vals = procedural_db_run_proc (gimp, context, progress,
|
||||
proc->name,
|
||||
&n_return_vals,
|
||||
GIMP_PDB_INT32, run_mode,
|
||||
GIMP_PDB_STRING, filename,
|
||||
GIMP_PDB_STRING, entered_filename,
|
||||
GIMP_PDB_END);
|
||||
|
||||
for (i = 0; i < proc->num_args; i++)
|
||||
args[i].arg_type = proc->args[i].arg_type;
|
||||
|
||||
args[0].value.pdb_int = run_mode;
|
||||
args[1].value.pdb_pointer = filename ? filename : (gchar *) uri;
|
||||
args[2].value.pdb_pointer = (gchar *) entered_filename;
|
||||
|
||||
return_vals = procedural_db_execute (gimp, context, progress,
|
||||
proc->name, args);
|
||||
|
||||
if (filename)
|
||||
g_free (filename);
|
||||
g_free (filename);
|
||||
|
||||
*status = return_vals[0].value.pdb_int;
|
||||
image_id = return_vals[1].value.pdb_int;
|
||||
|
||||
procedural_db_destroy_args (return_vals, proc->num_values);
|
||||
g_free (args);
|
||||
|
||||
if (*status == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
|
@ -221,27 +218,24 @@ file_open_thumbnail (Gimp *gimp,
|
|||
if (proc && proc->num_args >= 2 && proc->num_values >= 1)
|
||||
{
|
||||
GimpPDBStatusType status;
|
||||
Argument *args;
|
||||
Argument *return_vals;
|
||||
gint n_return_vals;
|
||||
gchar *filename;
|
||||
gint image_id;
|
||||
gint i;
|
||||
|
||||
filename = file_utils_filename_from_uri (uri);
|
||||
|
||||
args = g_new0 (Argument, proc->num_args);
|
||||
if (! filename)
|
||||
filename = g_strdup (uri);
|
||||
|
||||
for (i = 0; i < proc->num_args; i++)
|
||||
args[i].arg_type = proc->args[i].arg_type;
|
||||
return_vals = procedural_db_run_proc (gimp, context, progress,
|
||||
proc->name,
|
||||
&n_return_vals,
|
||||
GIMP_PDB_STRING, filename,
|
||||
GIMP_PDB_INT32, size,
|
||||
GIMP_PDB_END);
|
||||
|
||||
args[0].value.pdb_pointer = filename ? filename : (gchar *) uri;
|
||||
args[1].value.pdb_int = size;
|
||||
|
||||
return_vals = procedural_db_execute (gimp, context, progress,
|
||||
proc->name, args);
|
||||
|
||||
if (filename)
|
||||
g_free (filename);
|
||||
g_free (filename);
|
||||
|
||||
status = return_vals[0].value.pdb_int;
|
||||
image_id = return_vals[1].value.pdb_int;
|
||||
|
@ -253,7 +247,6 @@ file_open_thumbnail (Gimp *gimp,
|
|||
}
|
||||
|
||||
procedural_db_destroy_args (return_vals, proc->num_values);
|
||||
g_free (args);
|
||||
|
||||
if (status == GIMP_PDB_SUCCESS && image_id != -1)
|
||||
{
|
||||
|
|
|
@ -78,11 +78,10 @@ file_save (GimpImage *gimage,
|
|||
GError **error)
|
||||
{
|
||||
const ProcRecord *proc;
|
||||
Argument *args;
|
||||
Argument *return_vals;
|
||||
gint n_return_vals;
|
||||
GimpPDBStatusType status;
|
||||
gint i;
|
||||
gchar *filename = NULL;
|
||||
gchar *filename;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), GIMP_PDB_CALLING_ERROR);
|
||||
g_return_val_if_fail (GIMP_IS_CONTEXT (context), GIMP_PDB_CALLING_ERROR);
|
||||
|
@ -120,29 +119,31 @@ file_save (GimpImage *gimage,
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
filename = g_strdup (uri);
|
||||
}
|
||||
|
||||
/* ref the image, so it can't get deleted during save */
|
||||
g_object_ref (gimage);
|
||||
|
||||
proc = plug_in_proc_def_get_proc (file_proc);
|
||||
|
||||
args = g_new0 (Argument, proc->num_args);
|
||||
|
||||
for (i = 0; i < proc->num_args; i++)
|
||||
args[i].arg_type = proc->args[i].arg_type;
|
||||
|
||||
args[0].value.pdb_int = run_mode;
|
||||
args[1].value.pdb_int = gimp_image_get_ID (gimage);
|
||||
args[2].value.pdb_int =
|
||||
gimp_item_get_ID (GIMP_ITEM (gimp_image_active_drawable (gimage)));
|
||||
args[3].value.pdb_pointer = filename ? filename : (gchar *) uri;
|
||||
args[4].value.pdb_pointer = (gchar *) uri;
|
||||
|
||||
return_vals = procedural_db_execute (gimage->gimp, context, progress,
|
||||
proc->name, args);
|
||||
return_vals =
|
||||
procedural_db_run_proc (gimage->gimp, context, progress,
|
||||
proc->name,
|
||||
&n_return_vals,
|
||||
GIMP_PDB_INT32, run_mode,
|
||||
GIMP_PDB_IMAGE, gimp_image_get_ID (gimage),
|
||||
GIMP_PDB_DRAWABLE, gimp_item_get_ID (GIMP_ITEM (gimp_image_active_drawable (gimage))),
|
||||
GIMP_PDB_STRING, filename,
|
||||
GIMP_PDB_STRING, uri,
|
||||
GIMP_PDB_END);
|
||||
|
||||
status = return_vals[0].value.pdb_int;
|
||||
|
||||
procedural_db_destroy_args (return_vals, n_return_vals);
|
||||
|
||||
if (status == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
GimpDocumentList *documents;
|
||||
|
@ -183,9 +184,6 @@ file_save (GimpImage *gimage,
|
|||
_("Plug-In could not save image"));
|
||||
}
|
||||
|
||||
g_free (return_vals);
|
||||
g_free (args);
|
||||
|
||||
g_object_unref (gimage);
|
||||
|
||||
out:
|
||||
|
|
|
@ -1055,25 +1055,34 @@ plug_ins_add_to_db (Gimp *gimp,
|
|||
|
||||
if (proc_def->file_proc)
|
||||
{
|
||||
Argument args[4];
|
||||
Argument *return_vals;
|
||||
gint n_return_vals;
|
||||
|
||||
args[0].arg_type = GIMP_PDB_STRING;
|
||||
args[0].value.pdb_pointer = proc_def->db_info.name;
|
||||
if (proc_def->image_types)
|
||||
{
|
||||
return_vals =
|
||||
procedural_db_run_proc (gimp, context, NULL,
|
||||
"gimp-register-save-handler",
|
||||
&n_return_vals,
|
||||
GIMP_PDB_STRING, proc_def->db_info.name,
|
||||
GIMP_PDB_STRING, proc_def->extensions,
|
||||
GIMP_PDB_STRING, proc_def->prefixes,
|
||||
GIMP_PDB_END);
|
||||
}
|
||||
else
|
||||
{
|
||||
return_vals =
|
||||
procedural_db_run_proc (gimp, context, NULL,
|
||||
"gimp-register-magic-load-handler",
|
||||
&n_return_vals,
|
||||
GIMP_PDB_STRING, proc_def->db_info.name,
|
||||
GIMP_PDB_STRING, proc_def->extensions,
|
||||
GIMP_PDB_STRING, proc_def->prefixes,
|
||||
GIMP_PDB_STRING, proc_def->magics,
|
||||
GIMP_PDB_END);
|
||||
}
|
||||
|
||||
args[1].arg_type = GIMP_PDB_STRING;
|
||||
args[1].value.pdb_pointer = proc_def->extensions;
|
||||
|
||||
args[2].arg_type = GIMP_PDB_STRING;
|
||||
args[2].value.pdb_pointer = proc_def->prefixes;
|
||||
|
||||
args[3].arg_type = GIMP_PDB_STRING;
|
||||
args[3].value.pdb_pointer = proc_def->magics;
|
||||
|
||||
g_free (procedural_db_execute (gimp, context, NULL,
|
||||
proc_def->image_types ?
|
||||
"gimp-register-save-handler" :
|
||||
"gimp-register-magic-load-handler",
|
||||
args));
|
||||
procedural_db_destroy_args (return_vals, n_return_vals);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1055,25 +1055,34 @@ plug_ins_add_to_db (Gimp *gimp,
|
|||
|
||||
if (proc_def->file_proc)
|
||||
{
|
||||
Argument args[4];
|
||||
Argument *return_vals;
|
||||
gint n_return_vals;
|
||||
|
||||
args[0].arg_type = GIMP_PDB_STRING;
|
||||
args[0].value.pdb_pointer = proc_def->db_info.name;
|
||||
if (proc_def->image_types)
|
||||
{
|
||||
return_vals =
|
||||
procedural_db_run_proc (gimp, context, NULL,
|
||||
"gimp-register-save-handler",
|
||||
&n_return_vals,
|
||||
GIMP_PDB_STRING, proc_def->db_info.name,
|
||||
GIMP_PDB_STRING, proc_def->extensions,
|
||||
GIMP_PDB_STRING, proc_def->prefixes,
|
||||
GIMP_PDB_END);
|
||||
}
|
||||
else
|
||||
{
|
||||
return_vals =
|
||||
procedural_db_run_proc (gimp, context, NULL,
|
||||
"gimp-register-magic-load-handler",
|
||||
&n_return_vals,
|
||||
GIMP_PDB_STRING, proc_def->db_info.name,
|
||||
GIMP_PDB_STRING, proc_def->extensions,
|
||||
GIMP_PDB_STRING, proc_def->prefixes,
|
||||
GIMP_PDB_STRING, proc_def->magics,
|
||||
GIMP_PDB_END);
|
||||
}
|
||||
|
||||
args[1].arg_type = GIMP_PDB_STRING;
|
||||
args[1].value.pdb_pointer = proc_def->extensions;
|
||||
|
||||
args[2].arg_type = GIMP_PDB_STRING;
|
||||
args[2].value.pdb_pointer = proc_def->prefixes;
|
||||
|
||||
args[3].arg_type = GIMP_PDB_STRING;
|
||||
args[3].value.pdb_pointer = proc_def->magics;
|
||||
|
||||
g_free (procedural_db_execute (gimp, context, NULL,
|
||||
proc_def->image_types ?
|
||||
"gimp-register-save-handler" :
|
||||
"gimp-register-magic-load-handler",
|
||||
args));
|
||||
procedural_db_destroy_args (return_vals, n_return_vals);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue