Commit 1fbd1ad1 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

app/app_procs.[ch] let the GLib command-line parser deal with the

2005-02-03  Sven Neumann  <sven@gimp.org>

	* app/app_procs.[ch]
	* app/main.c: let the GLib command-line parser deal with the
	remaining arguments and pass a string array to app_run().
parent 8bc6352a
2005-02-03 Sven Neumann <sven@gimp.org>
* app/app_procs.[ch]
* app/main.c: let the GLib command-line parser deal with the
remaining arguments and pass a string array to app_run().
2005-02-03 Sven Neumann <sven@gimp.org>
* app/main.c: more work on the command-line option parser.
......
......@@ -151,8 +151,7 @@ app_exit (gint status)
void
app_run (const gchar *full_prog_name,
gint gimp_argc,
gchar **gimp_argv,
const gchar **filenames,
const gchar *alternate_system_gimprc,
const gchar *alternate_gimprc,
const gchar *session_name,
......@@ -297,63 +296,58 @@ app_run (const gchar *full_prog_name,
*/
gimp_rc_set_autosave (GIMP_RC (gimp->edit_config), TRUE);
/* Parse the rest of the command line arguments as images to load
/* Load the images given on the command-line.
*/
if (gimp_argc > 0)
if (filenames)
{
gint i;
for (i = 0; i < gimp_argc; i++)
for (i = 0; filenames[i]; i++)
{
if (gimp_argv[i])
{
GError *error = NULL;
gchar *uri;
GError *error = NULL;
gchar *uri;
/* first try if we got a file uri */
uri = g_filename_from_uri (gimp_argv[i], NULL, NULL);
/* first try if we got a file uri */
uri = g_filename_from_uri (filenames[i], NULL, NULL);
if (uri)
{
g_free (uri);
uri = g_strdup (gimp_argv[i]);
}
else
{
uri = file_utils_filename_to_uri (gimp->load_procs,
gimp_argv[i], &error);
}
if (! uri)
{
g_printerr ("conversion filename -> uri failed: %s\n",
error->message);
g_clear_error (&error);
}
else
{
GimpImage *gimage;
GimpPDBStatusType status;
if (uri)
{
g_free (uri);
uri = g_strdup (filenames[i]);
}
else
{
uri = file_utils_filename_to_uri (gimp->load_procs,
filenames[i], &error);
}
gimage = file_open_with_display (gimp,
gimp_get_user_context (gimp),
NULL,
uri,
&status, &error);
if (! uri)
{
g_printerr ("conversion filename -> uri failed: %s\n",
error->message);
g_clear_error (&error);
}
else
{
GimpImage *gimage;
GimpPDBStatusType status;
if (! gimage && status != GIMP_PDB_CANCEL)
{
gchar *filename = file_utils_uri_to_utf8_filename (uri);
gimage = file_open_with_display (gimp,
gimp_get_user_context (gimp),
NULL,
uri,
&status, &error);
g_message (_("Opening '%s' failed: %s"),
filename, error->message);
g_clear_error (&error);
if (! gimage && status != GIMP_PDB_CANCEL)
{
gchar *filename = file_utils_uri_to_utf8_filename (uri);
g_free (filename);
}
g_message (_("Opening '%s' failed: %s"),
filename, error->message);
g_clear_error (&error);
g_free (uri);
g_free (filename);
}
g_free (uri);
}
}
}
......
......@@ -33,8 +33,7 @@ void app_abort (gboolean no_interface,
void app_exit (gint status) G_GNUC_NORETURN;
void app_run (const gchar *full_prog_name,
gint gimp_argc,
gchar **gimp_argv,
const gchar **filenames,
const gchar *alternate_system_gimprc,
const gchar *alternate_gimprc,
const gchar *session_name,
......
......@@ -124,6 +124,7 @@ main (int argc,
const gchar *session_name = NULL;
const gchar *batch_interpreter = NULL;
const gchar **batch_commands = NULL;
const gchar **filenames = NULL;
gboolean fatal_warnings = FALSE;
gboolean no_interface = FALSE;
gboolean no_data = FALSE;
......@@ -230,22 +231,31 @@ main (int argc,
/* GTK+ also looks for --g-fatal-warnings, but we want it for
* non-interactive use also.
*/
{ "g-fatal-warnings", 0, G_OPTION_FLAG_HIDDEN,
{
"g-fatal-warnings", 0, G_OPTION_FLAG_HIDDEN,
G_OPTION_ARG_NONE, &fatal_warnings,
NULL, NULL
},
{ "dump-gimprc", 0, 0,
{
"dump-gimprc", 0, 0,
G_OPTION_ARG_CALLBACK, gimp_option_dump_gimprc,
N_("Output a gimprc file with default settings."), NULL
},
{ "dump-gimprc-system", 0, G_OPTION_FLAG_HIDDEN,
{
"dump-gimprc-system", 0, G_OPTION_FLAG_HIDDEN,
G_OPTION_ARG_CALLBACK, gimp_option_dump_gimprc,
NULL, NULL
},
{ "dump-gimprc-manpage", 0, G_OPTION_FLAG_HIDDEN,
{
"dump-gimprc-manpage", 0, G_OPTION_FLAG_HIDDEN,
G_OPTION_ARG_CALLBACK, gimp_option_dump_gimprc,
NULL, NULL
},
{
G_OPTION_REMAINING, 0, 0,
G_OPTION_ARG_FILENAME_ARRAY, &filenames,
NULL, NULL
},
{ NULL }
};
......@@ -383,8 +393,7 @@ main (int argc,
stack_trace_mode);
app_run (argv[0],
argc - 1,
argv + 1,
filenames,
system_gimprc,
user_gimprc,
session_name,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment