mirror of https://github.com/GNOME/gimp.git
added utility function that handles opening files passed on the
2007-01-22 Sven Neumann <sven@gimp.org> * app/file/file-open.[ch]: added utility function that handles opening files passed on the command-line. * app/app_procs.c * app/widgets/gimpdbusservice.c: use the new function instead of duplicating the code. svn path=/trunk/; revision=21759
This commit is contained in:
parent
98b060eb18
commit
6414b2ea5d
|
@ -1,3 +1,12 @@
|
|||
2007-01-22 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/file/file-open.[ch]: added utility function that handles
|
||||
opening files passed on the command-line.
|
||||
|
||||
* app/app_procs.c
|
||||
* app/widgets/gimpdbusservice.c: use the new function instead of
|
||||
duplicating the code.
|
||||
|
||||
2007-01-22 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* libgimp/gimppixbuf.c (gimp_pixbuf_from_data): free the thumbnail
|
||||
|
|
|
@ -45,7 +45,6 @@
|
|||
#include "core/gimp-user-install.h"
|
||||
|
||||
#include "file/file-open.h"
|
||||
#include "file/file-utils.h"
|
||||
|
||||
#ifndef GIMP_CONSOLE_COMPILATION
|
||||
#include "dialogs/user-install-dialog.h"
|
||||
|
@ -254,46 +253,7 @@ app_run (const gchar *full_prog_name,
|
|||
/* Load the images given on the command-line.
|
||||
*/
|
||||
if (filenames)
|
||||
{
|
||||
for (i = 0; filenames[i]; i++)
|
||||
{
|
||||
GError *error = NULL;
|
||||
gchar *uri;
|
||||
|
||||
uri = file_utils_any_to_uri (gimp, filenames[i], &error);
|
||||
|
||||
if (uri)
|
||||
{
|
||||
GimpImage *image;
|
||||
GimpPDBStatusType status;
|
||||
|
||||
image = file_open_with_display (gimp,
|
||||
gimp_get_user_context (gimp),
|
||||
NULL,
|
||||
uri,
|
||||
&status, &error);
|
||||
|
||||
if (! image && status != GIMP_PDB_CANCEL)
|
||||
{
|
||||
gchar *filename = file_utils_uri_to_utf8_filename (uri);
|
||||
|
||||
g_message (_("Opening '%s' failed: %s"),
|
||||
filename, error->message);
|
||||
g_clear_error (&error);
|
||||
|
||||
g_free (filename);
|
||||
}
|
||||
|
||||
g_free (uri);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_printerr ("conversion filename -> uri failed: %s\n",
|
||||
error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
}
|
||||
}
|
||||
file_open_from_command_line (gimp, filenames);
|
||||
|
||||
#ifndef GIMP_CONSOLE_COMPILATION
|
||||
if (! no_interface)
|
||||
|
|
|
@ -457,6 +457,60 @@ file_open_layers (Gimp *gimp,
|
|||
}
|
||||
|
||||
|
||||
/* This function is called for filenames passed on the command-line
|
||||
* or from the D-Bus service.
|
||||
*/
|
||||
void
|
||||
file_open_from_command_line (Gimp *gimp,
|
||||
const gchar **uris)
|
||||
{
|
||||
gint i;
|
||||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (uris != NULL);
|
||||
|
||||
for (i = 0; uris[i]; i++)
|
||||
{
|
||||
GError *error = NULL;
|
||||
gchar *uri;
|
||||
|
||||
/* we accept URIs and filenames */
|
||||
uri = file_utils_any_to_uri (gimp, uris[i], &error);
|
||||
|
||||
if (uri)
|
||||
{
|
||||
GimpImage *image;
|
||||
GimpPDBStatusType status;
|
||||
|
||||
image = file_open_with_display (gimp,
|
||||
gimp_get_user_context (gimp),
|
||||
NULL,
|
||||
uri,
|
||||
&status, &error);
|
||||
|
||||
if (! image && status != GIMP_PDB_CANCEL)
|
||||
{
|
||||
gchar *filename = file_utils_uri_to_utf8_filename (uri);
|
||||
|
||||
g_message (_("Opening '%s' failed: %s"),
|
||||
filename, error->message);
|
||||
g_clear_error (&error);
|
||||
|
||||
g_free (filename);
|
||||
}
|
||||
|
||||
g_free (uri);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_printerr ("conversion filename -> uri failed: %s\n",
|
||||
error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
|
||||
|
|
|
@ -68,5 +68,8 @@ GList * file_open_layers (Gimp *gimp,
|
|||
GimpPDBStatusType *status,
|
||||
GError **error);
|
||||
|
||||
void file_open_from_command_line (Gimp *gimp,
|
||||
const gchar **uris);
|
||||
|
||||
|
||||
#endif /* __FILE_OPEN_H__ */
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include "core/gimp.h"
|
||||
|
||||
#include "file/file-open.h"
|
||||
#include "file/file-utils.h"
|
||||
|
||||
#include "gimpdbusservice.h"
|
||||
#include "gimpdbusservice-glue.h"
|
||||
|
@ -72,37 +71,17 @@ gimp_dbus_service_new (Gimp *gimp)
|
|||
gboolean
|
||||
gimp_dbus_service_open (GimpDBusService *service,
|
||||
const gchar **uris,
|
||||
GError **error)
|
||||
GError **dbus_error)
|
||||
{
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_DBUS_SERVICE (service), FALSE);
|
||||
|
||||
for (i = 0; uris[i]; i++)
|
||||
if (uris && *uris)
|
||||
{
|
||||
GimpImage *image;
|
||||
gchar *uri;
|
||||
GimpPDBStatusType status;
|
||||
|
||||
/* the method is documented to take URIs but we also accept filenames */
|
||||
uri = file_utils_any_to_uri (service->gimp, uris[i], error);
|
||||
if (! uri)
|
||||
return FALSE;
|
||||
|
||||
image = file_open_with_display (service->gimp,
|
||||
gimp_get_user_context (service->gimp),
|
||||
NULL,
|
||||
uris[i],
|
||||
&status, error);
|
||||
g_free (uri);
|
||||
|
||||
if (! image && status != GIMP_PDB_CANCEL)
|
||||
return FALSE;
|
||||
file_open_from_command_line (service->gimp, uris);
|
||||
}
|
||||
|
||||
/* if no URI is passed, raise the toolbox */
|
||||
if (i == 0)
|
||||
else
|
||||
{
|
||||
/* if no URI is passed, raise the toolbox */
|
||||
const GList *managers = gimp_ui_managers_from_name ("<Image>");
|
||||
|
||||
if (managers)
|
||||
|
|
Loading…
Reference in New Issue