Commit 69122276 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

added run-mode parameter to file_open_layer().

2005-10-17  Sven Neumann  <sven@gimp.org>

	* app/file/file-open.[ch]: added run-mode parameter to
	file_open_layer().

	* app/dialogs/file-open-dialog.c
	* app/display/gimpdisplayshell-dnd.c
	* app/widgets/gimplayertreeview.c: pass GIMP_RUN_INTERACTIVE to
	file_open_layer().

	* tools/pdbgen/pdb/fileops.pdb: export file_open_layer() to the PDB
	as file-load-layer.

	* app/pdb/fileops_cmds.c
	* app/pdb/internal_procs.c
	* libgimp/gimpfileops_pdb.[ch]: regenerated.

	* libgimp/gimp.def: updated.
parent d9985157
2005-10-17 Sven Neumann <sven@gimp.org>
* app/file/file-open.[ch]: added run-mode parameter to
file_open_layer().
* app/dialogs/file-open-dialog.c
* app/display/gimpdisplayshell-dnd.c
* app/widgets/gimplayertreeview.c: pass GIMP_RUN_INTERACTIVE to
file_open_layer().
* tools/pdbgen/pdb/fileops.pdb: export file_open_layer() to the PDB
as file-load-layer.
* app/pdb/fileops_cmds.c
* app/pdb/internal_procs.c
* libgimp/gimpfileops_pdb.[ch]: regenerated.
* libgimp/gimp.def: updated.
2005-10-16 Akkana Peck <akkana@shallowsky.com>
* plug-ins/pygimp/plug-ins/gimpcons.py
......
......@@ -229,7 +229,7 @@ file_open_dialog_open_layer (GtkWidget *open_dialog,
new_layer = file_open_layer (gimage->gimp,
gimp_get_user_context (gimage->gimp),
GIMP_PROGRESS (open_dialog),
gimage, uri,
gimage, uri, GIMP_RUN_INTERACTIVE,
&status, &error);
if (new_layer)
......
......@@ -419,7 +419,7 @@ gimp_display_shell_drop_uri_list (GtkWidget *widget,
new_layer = file_open_layer (gimage->gimp, context,
GIMP_PROGRESS (shell->statusbar),
gimage, uri,
gimage, uri, GIMP_RUN_INTERACTIVE,
&status, &error);
if (new_layer)
......
......@@ -346,6 +346,7 @@ file_open_layer (Gimp *gimp,
GimpProgress *progress,
GimpImage *dest_image,
const gchar *uri,
GimpRunMode run_mode,
GimpPDBStatusType *status,
GError **error)
{
......@@ -363,7 +364,7 @@ file_open_layer (Gimp *gimp,
new_image = file_open_image (gimp, context, progress,
uri, uri,
NULL, GIMP_RUN_INTERACTIVE,
NULL, run_mode,
status, &mime_type, error);
if (new_image)
......
......@@ -62,6 +62,7 @@ GimpLayer * file_open_layer (Gimp *gimp,
GimpProgress *progress,
GimpImage *dest_image,
const gchar *uri,
GimpRunMode run_mode,
GimpPDBStatusType *status,
GError **error);
......
......@@ -49,14 +49,16 @@
#include "core/gimp.h"
#include "core/gimpimage.h"
#include "core/gimpimagefile.h"
#include "core/gimplayer.h"
#include "file/file-utils.h"
#include "plug-in/plug-in-proc-def.h"
#include "plug-in/plug-in.h"
#include "plug-in/plug-ins.h"
static ProcRecord file_load_proc;
static ProcRecord file_save_proc;
static ProcRecord file_load_layer_proc;
static ProcRecord file_load_thumbnail_proc;
static ProcRecord file_save_proc;
static ProcRecord file_save_thumbnail_proc;
static ProcRecord temp_name_proc;
static ProcRecord register_magic_load_handler_proc;
......@@ -69,8 +71,9 @@ void
register_fileops_procs (Gimp *gimp)
{
procedural_db_register (gimp, &file_load_proc);
procedural_db_register (gimp, &file_save_proc);
procedural_db_register (gimp, &file_load_layer_proc);
procedural_db_register (gimp, &file_load_thumbnail_proc);
procedural_db_register (gimp, &file_save_proc);
procedural_db_register (gimp, &file_save_thumbnail_proc);
procedural_db_register (gimp, &temp_name_proc);
procedural_db_register (gimp, &register_magic_load_handler_proc);
......@@ -155,7 +158,7 @@ static ProcRecord file_load_proc =
{
"gimp-file-load",
"gimp-file-load",
"Loads a file by invoking the right load handler.",
"Loads an image file by invoking the right load handler.",
"This procedure invokes the correct file load handler using magic if possible, and falling back on the file's extension and/or prefix if not. The name of the file to load is typically a full pathname, and the name entered is what the user actually typed before prepending a directory path. The reason for this is that if the user types http://www.xcf/~gimp/ he wants to fetch a URL, and the full pathname will not look like a URL.\"",
"Josh MacDonald",
"Josh MacDonald",
......@@ -170,49 +173,54 @@ static ProcRecord file_load_proc =
};
static Argument *
file_save_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
file_load_layer_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
Argument *new_args;
Argument *return_vals;
PlugInProcDef *file_proc;
const ProcRecord *proc;
gboolean success = TRUE;
Argument *return_args;
gint32 run_mode;
GimpImage *image;
gchar *filename;
GimpLayer *layer = NULL;
GimpPDBStatusType status;
gchar *uri;
gint i;
uri = file_utils_filename_to_uri (gimp->load_procs, (gchar *) args[3].value.pdb_pointer, NULL);
if (! uri)
return procedural_db_return_args (&file_save_proc, FALSE);
file_proc = file_utils_find_proc (gimp->save_procs, uri);
run_mode = args[0].value.pdb_int;
if (run_mode < GIMP_RUN_INTERACTIVE || run_mode > GIMP_RUN_NONINTERACTIVE)
success = FALSE;
g_free (uri);
image = gimp_image_get_by_ID (gimp, args[1].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
if (! file_proc)
return procedural_db_return_args (&file_save_proc, FALSE);
filename = (gchar *) args[2].value.pdb_pointer;
if (filename == NULL)
success = FALSE;
proc = plug_in_proc_def_get_proc (file_proc);
if (success)
{
uri = file_utils_filename_to_uri (gimp->load_procs, filename, NULL);
if (! uri)
success = FALSE;
new_args = g_new0 (Argument, proc->num_args);
memcpy (new_args, args, sizeof (Argument) * 5);
if (success)
layer = file_open_layer (gimp, context, progress,
image, uri, run_mode, &status, NULL);
for (i = 5; i < proc->num_args; i++)
{
new_args[i].arg_type = proc->args[i].arg_type;
if (proc->args[i].arg_type == GIMP_PDB_STRING)
new_args[i].value.pdb_pointer = g_strdup ("");
success = layer != NULL;
}
return_vals = procedural_db_execute (gimp, context, progress, proc->name, new_args);
g_free (new_args);
return_args = procedural_db_return_args (&file_load_layer_proc, success);
return return_vals;
if (success)
return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (layer));
return return_args;
}
static ProcArg file_save_inargs[] =
static ProcArg file_load_layer_inargs[] =
{
{
GIMP_PDB_INT32,
......@@ -222,41 +230,40 @@ static ProcArg file_save_inargs[] =
{
GIMP_PDB_IMAGE,
"image",
"Input image"
},
{
GIMP_PDB_DRAWABLE,
"drawable",
"Drawable to save"
"Destination image"
},
{
GIMP_PDB_STRING,
"filename",
"The name of the file to save the image in"
},
"The name of the file to load"
}
};
static ProcArg file_load_layer_outargs[] =
{
{
GIMP_PDB_STRING,
"raw-filename",
"The name as entered by the user"
GIMP_PDB_LAYER,
"layer",
"The layer created when loading the image file"
}
};
static ProcRecord file_save_proc =
static ProcRecord file_load_layer_proc =
{
"gimp-file-save",
"gimp-file-save",
"Saves a file by extension.",
"This procedure invokes the correct file save handler according to the file's extension and/or prefix. The name of the file to save is typically a full pathname, and the name entered is what the user actually typed before prepending a directory path. The reason for this is that if the user types http://www.xcf/~gimp/ she wants to fetch a URL, and the full pathname will not look like a URL.",
"Josh MacDonald",
"Josh MacDonald",
"1997",
"gimp-file-load-layer",
"gimp-file-load-layer",
"Loads an image file as a layer into an already opened image.",
"This procedure behaves like the file-load procedure but opens the specified image as a layer into an already opened image.",
"Sven Neumann",
"Sven Neumann",
"2005",
NULL,
GIMP_INTERNAL,
5,
file_save_inargs,
0,
NULL,
{ { file_save_invoker } }
3,
file_load_layer_inargs,
1,
file_load_layer_outargs,
{ { file_load_layer_invoker } }
};
static Argument *
......@@ -393,6 +400,96 @@ static ProcRecord file_load_thumbnail_proc =
{ { file_load_thumbnail_invoker } }
};
static Argument *
file_save_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
Argument *new_args;
Argument *return_vals;
PlugInProcDef *file_proc;
const ProcRecord *proc;
gchar *uri;
gint i;
uri = file_utils_filename_to_uri (gimp->load_procs, (gchar *) args[3].value.pdb_pointer, NULL);
if (! uri)
return procedural_db_return_args (&file_save_proc, FALSE);
file_proc = file_utils_find_proc (gimp->save_procs, uri);
g_free (uri);
if (! file_proc)
return procedural_db_return_args (&file_save_proc, FALSE);
proc = plug_in_proc_def_get_proc (file_proc);
new_args = g_new0 (Argument, proc->num_args);
memcpy (new_args, args, sizeof (Argument) * 5);
for (i = 5; i < proc->num_args; i++)
{
new_args[i].arg_type = proc->args[i].arg_type;
if (proc->args[i].arg_type == GIMP_PDB_STRING)
new_args[i].value.pdb_pointer = g_strdup ("");
}
return_vals = procedural_db_execute (gimp, context, progress, proc->name, new_args);
g_free (new_args);
return return_vals;
}
static ProcArg file_save_inargs[] =
{
{
GIMP_PDB_INT32,
"run-mode",
"The run mode: GIMP_RUN_INTERACTIVE (0) or GIMP_RUN_NONINTERACTIVE (1)"
},
{
GIMP_PDB_IMAGE,
"image",
"Input image"
},
{
GIMP_PDB_DRAWABLE,
"drawable",
"Drawable to save"
},
{
GIMP_PDB_STRING,
"filename",
"The name of the file to save the image in"
},
{
GIMP_PDB_STRING,
"raw-filename",
"The name as entered by the user"
}
};
static ProcRecord file_save_proc =
{
"gimp-file-save",
"gimp-file-save",
"Saves a file by extension.",
"This procedure invokes the correct file save handler according to the file's extension and/or prefix. The name of the file to save is typically a full pathname, and the name entered is what the user actually typed before prepending a directory path. The reason for this is that if the user types http://www.xcf/~gimp/ she wants to fetch a URL, and the full pathname will not look like a URL.",
"Josh MacDonald",
"Josh MacDonald",
"1997",
NULL,
GIMP_INTERNAL,
5,
file_save_inargs,
0,
NULL,
{ { file_save_invoker } }
};
static Argument *
file_save_thumbnail_invoker (Gimp *gimp,
GimpContext *context,
......
......@@ -77,7 +77,7 @@ void register_undo_procs (Gimp *gimp);
void register_unit_procs (Gimp *gimp);
void register_vectors_procs (Gimp *gimp);
/* 490 procedures registered total */
/* 491 procedures registered total */
void
internal_procs_init (Gimp *gimp,
......@@ -98,67 +98,67 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Buffer procedures"), 0.063);
register_buffer_procs (gimp);
(* status_callback) (NULL, _("Channel"), 0.078);
(* status_callback) (NULL, _("Channel"), 0.077);
register_channel_procs (gimp);
(* status_callback) (NULL, _("Color"), 0.098);
register_color_procs (gimp);
(* status_callback) (NULL, _("Context"), 0.131);
(* status_callback) (NULL, _("Context"), 0.13);
register_context_procs (gimp);
(* status_callback) (NULL, _("Convert"), 0.176);
(* status_callback) (NULL, _("Convert"), 0.175);
register_convert_procs (gimp);
(* status_callback) (NULL, _("Display procedures"), 0.182);
(* status_callback) (NULL, _("Display procedures"), 0.181);
register_display_procs (gimp);
(* status_callback) (NULL, _("Drawable procedures"), 0.192);
(* status_callback) (NULL, _("Drawable procedures"), 0.191);
register_drawable_procs (gimp);
(* status_callback) (NULL, _("Transformation procedures"), 0.263);
register_drawable_transform_procs (gimp);
(* status_callback) (NULL, _("Edit procedures"), 0.296);
(* status_callback) (NULL, _("Edit procedures"), 0.295);
register_edit_procs (gimp);
(* status_callback) (NULL, _("File Operations"), 0.327);
(* status_callback) (NULL, _("File Operations"), 0.326);
register_fileops_procs (gimp);
(* status_callback) (NULL, _("Floating selections"), 0.347);
(* status_callback) (NULL, _("Floating selections"), 0.348);
register_floating_sel_procs (gimp);
(* status_callback) (NULL, _("Font UI"), 0.359);
(* status_callback) (NULL, _("Font UI"), 0.36);
register_font_select_procs (gimp);
(* status_callback) (NULL, _("Fonts"), 0.365);
(* status_callback) (NULL, _("Fonts"), 0.367);
register_fonts_procs (gimp);
(* status_callback) (NULL, _("Gimprc procedures"), 0.369);
(* status_callback) (NULL, _("Gimprc procedures"), 0.371);
register_gimprc_procs (gimp);
(* status_callback) (NULL, _("Gradient"), 0.384);
(* status_callback) (NULL, _("Gradient"), 0.385);
register_gradient_procs (gimp);
(* status_callback) (NULL, _("Gradient UI"), 0.445);
(* status_callback) (NULL, _("Gradient UI"), 0.446);
register_gradient_select_procs (gimp);
(* status_callback) (NULL, _("Gradients"), 0.451);
(* status_callback) (NULL, _("Gradients"), 0.452);
register_gradients_procs (gimp);
(* status_callback) (NULL, _("Image grid procedures"), 0.461);
(* status_callback) (NULL, _("Image grid procedures"), 0.462);
register_grid_procs (gimp);
(* status_callback) (NULL, _("Guide procedures"), 0.482);
(* status_callback) (NULL, _("Guide procedures"), 0.483);
register_guides_procs (gimp);
(* status_callback) (NULL, _("Help procedures"), 0.494);
(* status_callback) (NULL, _("Help procedures"), 0.495);
register_help_procs (gimp);
(* status_callback) (NULL, _("Image"), 0.496);
(* status_callback) (NULL, _("Image"), 0.497);
register_image_procs (gimp);
(* status_callback) (NULL, _("Layer"), 0.624);
(* status_callback) (NULL, _("Layer"), 0.625);
register_layer_procs (gimp);
(* status_callback) (NULL, _("Message procedures"), 0.68);
......@@ -170,22 +170,22 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Paint Tool procedures"), 0.692);
register_paint_tools_procs (gimp);
(* status_callback) (NULL, _("Palette"), 0.722);
(* status_callback) (NULL, _("Palette"), 0.723);
register_palette_procs (gimp);
(* status_callback) (NULL, _("Palette UI"), 0.751);
(* status_callback) (NULL, _("Palette UI"), 0.752);
register_palette_select_procs (gimp);
(* status_callback) (NULL, _("Palettes"), 0.757);
(* status_callback) (NULL, _("Palettes"), 0.758);
register_palettes_procs (gimp);
(* status_callback) (NULL, _("Parasite procedures"), 0.765);
(* status_callback) (NULL, _("Parasite procedures"), 0.766);
register_parasite_procs (gimp);
(* status_callback) (NULL, _("Paths"), 0.79);
register_paths_procs (gimp);
(* status_callback) (NULL, _("Pattern"), 0.822);
(* status_callback) (NULL, _("Pattern"), 0.823);
register_pattern_procs (gimp);
(* status_callback) (NULL, _("Pattern UI"), 0.827);
......@@ -200,13 +200,13 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Procedural database"), 0.853);
register_procedural_db_procs (gimp);
(* status_callback) (NULL, _("Progress"), 0.871);
(* status_callback) (NULL, _("Progress"), 0.872);
register_progress_procs (gimp);
(* status_callback) (NULL, _("Image mask"), 0.888);
register_selection_procs (gimp);
(* status_callback) (NULL, _("Selection Tool procedures"), 0.922);
(* status_callback) (NULL, _("Selection Tool procedures"), 0.923);
register_selection_tools_procs (gimp);
(* status_callback) (NULL, _("Text procedures"), 0.933);
......
......@@ -737,7 +737,8 @@ gimp_layer_tree_view_drop_uri_list (GimpContainerTreeView *view,
GError *error = NULL;
new_layer = file_open_layer (gimage->gimp, item_view->context, NULL,
gimage, uri, &status, &error);
gimage, uri, GIMP_RUN_INTERACTIVE,
&status, &error);
if (new_layer)
{
......
2005-10-17 Sven Neumann <sven@gimp.org>
* libgimp/libgimp-sections.txt
* libgimp/tmpl/gimpfileops.sgml: updated.
2005-10-05 Sven Neumann <sven@gimp.org>
* libgimp/libgimp-docs.sgml
......
......@@ -360,6 +360,7 @@ gimp_edit_stroke
<FILE>gimpfileops</FILE>
gimp_temp_name
gimp_file_load
gimp_file_load_layer
gimp_file_save
gimp_register_magic_load_handler
gimp_register_load_handler
......
......@@ -38,6 +38,17 @@ File operations (load, save, etc.)
@Returns:
<!-- ##### FUNCTION gimp_file_load_layer ##### -->
<para>
</para>
@run_mode:
@image_ID:
@filename:
@Returns:
<!-- ##### FUNCTION gimp_file_save ##### -->
<para>
......
......@@ -195,6 +195,7 @@ EXPORTS
gimp_extension_enable
gimp_extension_process
gimp_file_load
gimp_file_load_layer
gimp_file_save
gimp_fill_type_get_type
gimp_flip
......
......@@ -31,7 +31,7 @@
* @filename: The name of the file to load.
* @raw_filename: The name as entered by the user.
*
* Loads a file by invoking the right load handler.
* Loads an image file by invoking the right load handler.
*
* This procedure invokes the correct file load handler using magic if
* possible, and falling back on the file's extension and/or prefix if
......@@ -67,6 +67,45 @@ gimp_file_load (GimpRunMode run_mode,
return image_ID;
}
/**
* gimp_file_load_layer:
* @run_mode: The run mode.
* @image_ID: Destination image.
* @filename: The name of the file to load.
*
* Loads an image file as a layer into an already opened image.
*
* This procedure behaves like the file-load procedure but opens the
* specified image as a layer into an already opened image.
*
* Returns: The layer created when loading the image file.
*
* Since: GIMP 2.4
*/
gint32
gimp_file_load_layer (GimpRunMode run_mode,
gint32 image_ID,
const gchar *filename)
{
GimpParam *return_vals;
gint nreturn_vals;
gint32 layer_ID = -1;
return_vals = gimp_run_procedure ("gimp-file-load-layer",
&nreturn_vals,
GIMP_PDB_INT32, run_mode,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_STRING, filename,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
layer_ID = return_vals[1].data.d_layer;
gimp_destroy_params (return_vals, nreturn_vals);
return layer_ID;
}
/**
* gimp_file_save:
* @run_mode: The run mode.
......
......@@ -32,6 +32,9 @@ G_BEGIN_DECLS
gint32 gimp_file_load (GimpRunMode run_mode,
const gchar *filename,
const gchar *raw_filename);
gint32 gimp_file_load_layer (GimpRunMode run_mode,
gint32 image_ID,
const gchar *filename);
gboolean gimp_file_save (GimpRunMode run_mode,
gint32 image_ID,
gint32 drawable_ID,
......
......@@ -49,7 +49,7 @@ sub handler_args {
# The defs
sub file_load {
$blurb = 'Loads a file by invoking the right load handler.';
$blurb = 'Loads an image file by invoking the right load handler.';
$help = <<'HELP';
This procedure invokes the correct file load handler using magic if possible,
......@@ -115,6 +115,51 @@ CODE
);
}
sub file_load_layer {
$blurb = 'Loads an image file as a layer into an already opened image.';
$help = <<'HELP';
This procedure behaves like the file-load procedure but opens the specified
image as a layer into an already opened image.
HELP
$author = $copyright = 'Sven Neumann';
$date = '2005';
$since = '2.4';
@inargs = (
{ name => 'run_mode',
type => 'enum GimpRunMode (no GIMP_RUN_WITH_LAST_VALS)',
<