1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (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
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-05-02 04:22:55 +08:00
|
|
|
|
2000-06-08 01:16:45 +08:00
|
|
|
/* Author: Josh MacDonald. */
|
|
|
|
|
2000-05-02 04:22:55 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <errno.h>
|
2000-05-02 04:22:55 +08:00
|
|
|
|
|
|
|
#include <libgimp/gimp.h>
|
2004-07-17 05:24:39 +08:00
|
|
|
#include <libgimp/gimpui.h>
|
2000-05-02 04:22:55 +08:00
|
|
|
|
|
|
|
#include "libgimp/stdplugins-intl.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-06-08 01:16:45 +08:00
|
|
|
#define TIMEOUT "300"
|
2000-06-26 06:23:18 +08:00
|
|
|
#define BUFSIZE 1024
|
2000-06-08 01:16:45 +08:00
|
|
|
|
2003-07-02 02:54:28 +08:00
|
|
|
static void query (void);
|
|
|
|
static void run (const gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-07-02 02:54:28 +08:00
|
|
|
static gint32 load_image (const gchar *filename,
|
|
|
|
GimpRunMode run_mode,
|
|
|
|
GimpPDBStatusType *status /* return value */);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-06-08 01:16:45 +08:00
|
|
|
GimpPlugInInfo PLUG_IN_INFO =
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-01-26 01:46:56 +08:00
|
|
|
NULL, /* init_proc */
|
|
|
|
NULL, /* quit_proc */
|
|
|
|
query, /* query_proc */
|
|
|
|
run, /* run_proc */
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
MAIN ()
|
|
|
|
|
|
|
|
static void
|
2000-01-26 01:46:56 +08:00
|
|
|
query (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-06-08 01:16:45 +08:00
|
|
|
static GimpParamDef load_args[] =
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
|
|
|
|
{ GIMP_PDB_STRING, "filename", "The name of the file to load" },
|
|
|
|
{ GIMP_PDB_STRING, "raw_filename", "The name entered" }
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
2000-05-02 04:22:55 +08:00
|
|
|
|
2000-06-08 01:16:45 +08:00
|
|
|
static GimpParamDef load_return_vals[] =
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
{ GIMP_PDB_IMAGE, "image", "Output image" }
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
gimp_install_procedure ("file_url_load",
|
2000-01-31 10:32:30 +08:00
|
|
|
"loads files given a URL",
|
|
|
|
"You need to have GNU Wget installed.",
|
1997-11-25 06:05:25 +08:00
|
|
|
"Spencer Kimball & Peter Mattis",
|
|
|
|
"Spencer Kimball & Peter Mattis",
|
|
|
|
"1995-1997",
|
2004-07-17 06:45:03 +08:00
|
|
|
N_("URL"),
|
1997-11-25 06:05:25 +08:00
|
|
|
NULL,
|
2000-08-22 09:26:57 +08:00
|
|
|
GIMP_PLUGIN,
|
2001-12-06 10:28:58 +08:00
|
|
|
G_N_ELEMENTS (load_args),
|
|
|
|
G_N_ELEMENTS (load_return_vals),
|
1997-11-25 06:05:25 +08:00
|
|
|
load_args, load_return_vals);
|
|
|
|
|
2004-07-17 06:45:03 +08:00
|
|
|
gimp_plugin_menu_register ("file_url_load", "<Load>");
|
|
|
|
gimp_plugin_icon_register ("file_url_load",
|
|
|
|
GIMP_ICON_TYPE_STOCK_ID, GIMP_STOCK_WEB);
|
2000-01-26 01:46:56 +08:00
|
|
|
gimp_register_load_handler ("file_url_load",
|
|
|
|
"",
|
2003-04-23 21:38:28 +08:00
|
|
|
"http:,https:,ftp:");
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-07-02 02:54:28 +08:00
|
|
|
run (const gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-06-08 01:16:45 +08:00
|
|
|
static GimpParam values[2];
|
2002-01-08 17:20:02 +08:00
|
|
|
GimpRunMode run_mode;
|
2000-08-22 09:26:57 +08:00
|
|
|
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
2000-06-08 01:16:45 +08:00
|
|
|
gint32 image_ID;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
run_mode = param[0].data.d_int32;
|
|
|
|
|
|
|
|
*nreturn_vals = 1;
|
2000-01-26 01:46:56 +08:00
|
|
|
*return_vals = values;
|
2000-08-22 09:26:57 +08:00
|
|
|
values[0].type = GIMP_PDB_STATUS;
|
|
|
|
values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (strcmp (name, "file_url_load") == 0)
|
|
|
|
{
|
2000-06-08 01:16:45 +08:00
|
|
|
image_ID = load_image (param[2].data.d_string,
|
|
|
|
run_mode,
|
|
|
|
&status);
|
2000-01-26 01:46:56 +08:00
|
|
|
|
|
|
|
if (image_ID != -1 &&
|
2000-08-22 09:26:57 +08:00
|
|
|
status == GIMP_PDB_SUCCESS)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
*nreturn_vals = 2;
|
2000-08-22 09:26:57 +08:00
|
|
|
values[1].type = GIMP_PDB_IMAGE;
|
1997-11-25 06:05:25 +08:00
|
|
|
values[1].data.d_image = image_ID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2000-01-26 01:46:56 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
2000-01-26 01:46:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
values[0].data.d_status = status;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static gint32
|
2003-07-02 02:54:28 +08:00
|
|
|
load_image (const gchar *filename,
|
|
|
|
GimpRunMode run_mode,
|
2000-06-08 01:16:45 +08:00
|
|
|
GimpPDBStatusType *status)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-08-25 23:38:38 +08:00
|
|
|
gint32 image_ID;
|
|
|
|
gchar *ext = strrchr (filename, '.');
|
|
|
|
gchar *tmpname;
|
|
|
|
gint pid;
|
2000-11-09 05:58:22 +08:00
|
|
|
gint wpid;
|
2000-08-25 23:38:38 +08:00
|
|
|
gint process_status;
|
|
|
|
gint p[2];
|
2004-06-21 08:48:44 +08:00
|
|
|
gboolean name_image = FALSE;
|
|
|
|
|
|
|
|
fprintf (stderr, "Loading URL: %s\n", filename);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (!ext || ext[1] == 0 || strchr(ext, '/'))
|
2004-06-21 08:48:44 +08:00
|
|
|
tmpname = gimp_temp_name ("xxx");
|
|
|
|
else
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-06-21 08:48:44 +08:00
|
|
|
tmpname = gimp_temp_name (ext + 1);
|
|
|
|
name_image = TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-06-08 01:16:45 +08:00
|
|
|
if (pipe (p) != 0)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-06-13 22:37:00 +08:00
|
|
|
g_message ("pipe() failed: %s", g_strerror (errno));
|
1999-10-28 06:16:20 +08:00
|
|
|
g_free (tmpname);
|
2000-08-22 09:26:57 +08:00
|
|
|
*status = GIMP_PDB_EXECUTION_ERROR;
|
1997-11-25 06:05:25 +08:00
|
|
|
return -1;
|
|
|
|
}
|
2000-06-08 01:16:45 +08:00
|
|
|
|
|
|
|
if ((pid = fork()) < 0)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-06-13 22:37:00 +08:00
|
|
|
g_message ("fork() failed: %s", g_strerror (errno));
|
1999-10-28 06:16:20 +08:00
|
|
|
g_free (tmpname);
|
2000-08-22 09:26:57 +08:00
|
|
|
*status = GIMP_PDB_EXECUTION_ERROR;
|
2000-06-08 01:16:45 +08:00
|
|
|
return -1;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2000-06-08 01:16:45 +08:00
|
|
|
else if (pid == 0)
|
1999-04-30 02:20:46 +08:00
|
|
|
{
|
2000-06-08 01:16:45 +08:00
|
|
|
close (p[0]);
|
|
|
|
close (2);
|
|
|
|
dup (p[1]);
|
|
|
|
close (p[1]);
|
2000-11-13 17:30:09 +08:00
|
|
|
|
|
|
|
#ifdef HAVE_PUTENV
|
|
|
|
/* produce deterministic output */
|
|
|
|
putenv ("LANGUAGE=C");
|
|
|
|
putenv ("LC_ALL=C");
|
|
|
|
putenv ("LANG=C");
|
|
|
|
#endif
|
|
|
|
|
2000-06-08 01:16:45 +08:00
|
|
|
execlp ("wget", "wget", "-T", TIMEOUT, filename, "-O", tmpname, NULL);
|
2003-06-13 22:37:00 +08:00
|
|
|
g_message ("exec() failed: wget: %s", g_strerror (errno));
|
1999-10-28 06:16:20 +08:00
|
|
|
g_free (tmpname);
|
2000-06-08 01:16:45 +08:00
|
|
|
_exit (127);
|
1999-04-30 02:20:46 +08:00
|
|
|
}
|
2000-06-08 01:16:45 +08:00
|
|
|
else
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
if (run_mode == GIMP_RUN_NONINTERACTIVE)
|
2000-06-08 01:16:45 +08:00
|
|
|
{
|
2000-11-09 05:58:22 +08:00
|
|
|
wpid = waitpid (pid, &process_status, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-11-09 05:58:22 +08:00
|
|
|
if ((wpid < 0)
|
|
|
|
|| !WIFEXITED (process_status)
|
|
|
|
|| (WEXITSTATUS (process_status) != 0))
|
2000-06-08 01:16:45 +08:00
|
|
|
{
|
2004-01-20 19:24:14 +08:00
|
|
|
g_message ("wget exited abnormally on URL '%s'", filename);
|
2000-06-08 01:16:45 +08:00
|
|
|
g_free (tmpname);
|
2000-08-22 09:26:57 +08:00
|
|
|
*status = GIMP_PDB_EXECUTION_ERROR;
|
2000-06-08 01:16:45 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-06-08 01:16:45 +08:00
|
|
|
FILE *input;
|
2000-06-26 06:23:18 +08:00
|
|
|
gchar buf[BUFSIZE];
|
2002-04-11 07:10:37 +08:00
|
|
|
gboolean seen_resolve = FALSE;
|
2000-06-08 01:16:45 +08:00
|
|
|
gboolean connected = FALSE;
|
|
|
|
gboolean file_found = FALSE;
|
|
|
|
gchar sizestr[32];
|
|
|
|
gint size = 0;
|
|
|
|
gchar *message;
|
|
|
|
gint i, j;
|
|
|
|
gchar dot;
|
|
|
|
gint kilobytes = 0;
|
|
|
|
gboolean finished = FALSE;
|
|
|
|
|
|
|
|
gboolean debug = FALSE;
|
|
|
|
|
|
|
|
#define DEBUG(x) if (debug) fprintf (stderr, (x))
|
|
|
|
|
|
|
|
close (p[1]);
|
|
|
|
|
|
|
|
input = fdopen (p[0], "r");
|
|
|
|
|
|
|
|
/* hardcoded and not-really-foolproof scanning of wget putput */
|
|
|
|
|
2000-06-26 06:23:18 +08:00
|
|
|
if (fgets (buf, BUFSIZE, input) == NULL)
|
2000-06-08 01:16:45 +08:00
|
|
|
{
|
|
|
|
/* no message here because failing on the first line means
|
|
|
|
* that wget was not found
|
|
|
|
*/
|
|
|
|
g_free (tmpname);
|
2000-08-22 09:26:57 +08:00
|
|
|
*status = GIMP_PDB_EXECUTION_ERROR;
|
2000-06-08 01:16:45 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEBUG (buf);
|
|
|
|
|
|
|
|
/* The second line is the local copy of the file */
|
2000-06-26 06:23:18 +08:00
|
|
|
if (fgets (buf, BUFSIZE, input) == NULL)
|
2000-06-08 01:16:45 +08:00
|
|
|
{
|
2004-01-20 19:24:14 +08:00
|
|
|
g_message ("wget exited abnormally on URL '%s'", filename);
|
2000-06-08 01:16:45 +08:00
|
|
|
g_free (tmpname);
|
2000-08-22 09:26:57 +08:00
|
|
|
*status = GIMP_PDB_EXECUTION_ERROR;
|
2000-06-08 01:16:45 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEBUG (buf);
|
|
|
|
|
|
|
|
/* The third line is "Connecting to..." */
|
|
|
|
gimp_progress_init ("Connecting to server... "
|
|
|
|
"(timeout is "TIMEOUT" seconds)");
|
|
|
|
|
2002-04-11 07:10:37 +08:00
|
|
|
read_connect:
|
2000-06-26 06:23:18 +08:00
|
|
|
if (fgets (buf, BUFSIZE, input) == NULL)
|
2000-06-08 01:16:45 +08:00
|
|
|
{
|
2004-01-20 19:24:14 +08:00
|
|
|
g_message ("wget exited abnormally on URL '%s'", filename);
|
2000-06-08 01:16:45 +08:00
|
|
|
g_free (tmpname);
|
2000-08-22 09:26:57 +08:00
|
|
|
*status = GIMP_PDB_EXECUTION_ERROR;
|
2000-06-08 01:16:45 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else if (strstr (buf, "connected"))
|
|
|
|
{
|
|
|
|
connected = TRUE;
|
|
|
|
}
|
2002-04-11 07:10:37 +08:00
|
|
|
/* newer wgets have a "Resolving foo" line, so eat it */
|
|
|
|
else if (!seen_resolve && strstr (buf, "Resolving"))
|
|
|
|
{
|
|
|
|
seen_resolve = TRUE;
|
|
|
|
goto read_connect;
|
|
|
|
}
|
2000-06-08 01:16:45 +08:00
|
|
|
|
|
|
|
DEBUG (buf);
|
|
|
|
|
|
|
|
/* The fourth line is either the network request or an error */
|
|
|
|
gimp_progress_init ("Opening URL... "
|
|
|
|
"(timeout is "TIMEOUT" seconds)");
|
|
|
|
|
2000-06-26 06:23:18 +08:00
|
|
|
if (fgets (buf, BUFSIZE, input) == NULL)
|
2000-06-08 01:16:45 +08:00
|
|
|
{
|
2004-01-20 19:24:14 +08:00
|
|
|
g_message ("wget exited abnormally on URL '%s'", filename);
|
2000-06-08 01:16:45 +08:00
|
|
|
g_free (tmpname);
|
2000-08-22 09:26:57 +08:00
|
|
|
*status = GIMP_PDB_EXECUTION_ERROR;
|
2000-06-08 01:16:45 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else if (! connected)
|
|
|
|
{
|
2003-06-13 22:37:00 +08:00
|
|
|
g_message ("A network error occured: %s", buf);
|
2000-06-08 01:16:45 +08:00
|
|
|
|
|
|
|
DEBUG (buf);
|
|
|
|
|
|
|
|
g_free (tmpname);
|
2000-08-22 09:26:57 +08:00
|
|
|
*status = GIMP_PDB_EXECUTION_ERROR;
|
2000-06-08 01:16:45 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEBUG (buf);
|
|
|
|
|
|
|
|
/* The fifth line is either the length of the file or an error */
|
2000-06-26 06:23:18 +08:00
|
|
|
if (fgets (buf, BUFSIZE, input) == NULL)
|
2000-06-08 01:16:45 +08:00
|
|
|
{
|
2004-01-20 19:24:14 +08:00
|
|
|
g_message ("wget exited abnormally on URL '%s'", filename);
|
2000-06-08 01:16:45 +08:00
|
|
|
g_free (tmpname);
|
2000-08-22 09:26:57 +08:00
|
|
|
*status = GIMP_PDB_EXECUTION_ERROR;
|
2000-06-08 01:16:45 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else if (strstr (buf, "Length"))
|
|
|
|
{
|
|
|
|
file_found = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-06-13 22:37:00 +08:00
|
|
|
g_message ("A network error occured: %s", buf);
|
2000-06-08 01:16:45 +08:00
|
|
|
|
|
|
|
DEBUG (buf);
|
|
|
|
|
|
|
|
g_free (tmpname);
|
2000-08-22 09:26:57 +08:00
|
|
|
*status = GIMP_PDB_EXECUTION_ERROR;
|
2000-06-08 01:16:45 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEBUG (buf);
|
|
|
|
|
|
|
|
if (sscanf (buf, "Length: %31s", sizestr) != 1)
|
|
|
|
{
|
2003-06-13 22:37:00 +08:00
|
|
|
g_message ("Could not parse wget's file length message");
|
2000-06-08 01:16:45 +08:00
|
|
|
g_free (tmpname);
|
2000-08-22 09:26:57 +08:00
|
|
|
*status = GIMP_PDB_EXECUTION_ERROR;
|
2000-06-08 01:16:45 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* strip away commas */
|
|
|
|
for (i = 0, j = 0; i < sizeof (sizestr); i++, j++)
|
|
|
|
{
|
|
|
|
if (sizestr[i] == ',')
|
|
|
|
i++;
|
|
|
|
|
|
|
|
sizestr[j] = sizestr[i];
|
|
|
|
|
|
|
|
if (sizestr[j] == '\0')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
size = atoi (sizestr);
|
|
|
|
|
|
|
|
/* Start the actual download... */
|
|
|
|
message = g_strdup_printf ("Downloading %d bytes of image data... "
|
|
|
|
"(timeout is "TIMEOUT" seconds)", size);
|
|
|
|
gimp_progress_init (message);
|
|
|
|
g_free (message);
|
|
|
|
|
|
|
|
/* Switch to byte parsing wget's output... */
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
dot = fgetc (input);
|
|
|
|
|
2002-04-11 07:10:37 +08:00
|
|
|
if (feof (input))
|
2000-06-08 01:16:45 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (debug)
|
|
|
|
{
|
|
|
|
fputc (dot, stderr);
|
|
|
|
fflush (stderr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dot == '.') /* one kilobyte */
|
|
|
|
{
|
|
|
|
kilobytes++;
|
|
|
|
gimp_progress_update ((gdouble) (kilobytes * 1024) /
|
|
|
|
(gdouble) size);
|
|
|
|
}
|
|
|
|
else if (dot == ':') /* the time string contains a ':' */
|
|
|
|
{
|
2000-06-26 06:23:18 +08:00
|
|
|
fgets (buf, BUFSIZE, input);
|
2000-06-08 01:16:45 +08:00
|
|
|
|
|
|
|
DEBUG (buf);
|
|
|
|
|
|
|
|
if (! strstr (buf, "error"))
|
|
|
|
{
|
|
|
|
finished = TRUE;
|
|
|
|
gimp_progress_update (1.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! finished)
|
|
|
|
{
|
2003-06-13 22:37:00 +08:00
|
|
|
g_message ("wget exited before finishing downloading URL\n'%s'",
|
2000-06-08 01:16:45 +08:00
|
|
|
filename);
|
|
|
|
unlink (tmpname);
|
|
|
|
g_free (tmpname);
|
2000-08-22 09:26:57 +08:00
|
|
|
*status = GIMP_PDB_EXECUTION_ERROR;
|
2000-06-08 01:16:45 +08:00
|
|
|
return -1;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-08-25 23:38:38 +08:00
|
|
|
image_ID = gimp_file_load (GIMP_RUN_INTERACTIVE, tmpname, tmpname);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
unlink (tmpname);
|
1999-10-28 06:16:20 +08:00
|
|
|
g_free (tmpname);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-08-25 23:38:38 +08:00
|
|
|
if (image_ID != -1)
|
2000-01-26 01:46:56 +08:00
|
|
|
{
|
2000-08-25 23:38:38 +08:00
|
|
|
*status = GIMP_PDB_SUCCESS;
|
2004-06-21 08:48:44 +08:00
|
|
|
if (name_image)
|
|
|
|
gimp_image_set_filename (image_ID, filename);
|
|
|
|
else
|
|
|
|
gimp_image_set_filename (image_ID, "");
|
2000-01-26 01:46:56 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2000-08-25 23:38:38 +08:00
|
|
|
*status = GIMP_PDB_EXECUTION_ERROR;
|
|
|
|
|
|
|
|
return image_ID;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|