mirror of https://github.com/GNOME/gimp.git
app: port file-open and file-save to the new file-remote utilities
but only use them if GIMP_HANDLE_REMOTE_FILES is set.
This commit is contained in:
parent
af40c076d4
commit
c91b63f8ab
|
@ -53,6 +53,7 @@
|
||||||
|
|
||||||
#include "file-open.h"
|
#include "file-open.h"
|
||||||
#include "file-procedure.h"
|
#include "file-procedure.h"
|
||||||
|
#include "file-remote.h"
|
||||||
#include "file-utils.h"
|
#include "file-utils.h"
|
||||||
#include "gimp-file.h"
|
#include "gimp-file.h"
|
||||||
|
|
||||||
|
@ -91,6 +92,8 @@ file_open_image (Gimp *gimp,
|
||||||
{
|
{
|
||||||
GimpValueArray *return_vals;
|
GimpValueArray *return_vals;
|
||||||
GimpImage *image = NULL;
|
GimpImage *image = NULL;
|
||||||
|
GFile *local_file = NULL;
|
||||||
|
gboolean mounted = TRUE;
|
||||||
gchar *path = NULL;
|
gchar *path = NULL;
|
||||||
gchar *entered_uri = NULL;
|
gchar *entered_uri = NULL;
|
||||||
|
|
||||||
|
@ -142,7 +145,29 @@ file_open_image (Gimp *gimp,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! file_proc->handles_uri)
|
if (! file_proc->handles_uri)
|
||||||
path = g_file_get_path (file);
|
{
|
||||||
|
path = g_file_get_path (file);
|
||||||
|
|
||||||
|
if (! path && g_getenv ("GIMP_HANDLE_REMOTE_FILES"))
|
||||||
|
{
|
||||||
|
GError *my_error = NULL;
|
||||||
|
|
||||||
|
local_file = file_remote_download_image (gimp, file, &mounted,
|
||||||
|
progress, &my_error);
|
||||||
|
|
||||||
|
if (! local_file)
|
||||||
|
{
|
||||||
|
if (my_error)
|
||||||
|
g_propagate_error (error, my_error);
|
||||||
|
else
|
||||||
|
*status = GIMP_PDB_CANCEL;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
path = g_file_get_path (local_file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (! path)
|
if (! path)
|
||||||
path = g_file_get_uri (file);
|
path = g_file_get_uri (file);
|
||||||
|
@ -167,10 +192,22 @@ file_open_image (Gimp *gimp,
|
||||||
*status = g_value_get_enum (gimp_value_array_index (return_vals, 0));
|
*status = g_value_get_enum (gimp_value_array_index (return_vals, 0));
|
||||||
|
|
||||||
if (*status == GIMP_PDB_SUCCESS)
|
if (*status == GIMP_PDB_SUCCESS)
|
||||||
{
|
image = gimp_value_get_image (gimp_value_array_index (return_vals, 1),
|
||||||
image = gimp_value_get_image (gimp_value_array_index (return_vals, 1),
|
gimp);
|
||||||
gimp);
|
|
||||||
|
|
||||||
|
if (local_file)
|
||||||
|
{
|
||||||
|
if (image)
|
||||||
|
gimp_image_set_file (image, file);
|
||||||
|
|
||||||
|
if (! mounted)
|
||||||
|
g_file_delete (local_file, NULL, NULL);
|
||||||
|
|
||||||
|
g_object_unref (local_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*status == GIMP_PDB_SUCCESS)
|
||||||
|
{
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
file_open_sanitize_image (image, as_new);
|
file_open_sanitize_image (image, as_new);
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
|
|
||||||
#include "plug-in/gimppluginprocedure.h"
|
#include "plug-in/gimppluginprocedure.h"
|
||||||
|
|
||||||
|
#include "file-remote.h"
|
||||||
#include "file-save.h"
|
#include "file-save.h"
|
||||||
#include "file-utils.h"
|
#include "file-utils.h"
|
||||||
#include "gimp-file.h"
|
#include "gimp-file.h"
|
||||||
|
@ -66,8 +67,10 @@ file_save (Gimp *gimp,
|
||||||
GimpDrawable *drawable;
|
GimpDrawable *drawable;
|
||||||
GimpValueArray *return_vals;
|
GimpValueArray *return_vals;
|
||||||
GimpPDBStatusType status;
|
GimpPDBStatusType status;
|
||||||
gchar *filename = NULL;
|
GFile *local_file = NULL;
|
||||||
gchar *uri = NULL;
|
gboolean mounted = TRUE;
|
||||||
|
gchar *path = NULL;
|
||||||
|
gchar *uri = NULL;
|
||||||
gint32 image_ID;
|
gint32 image_ID;
|
||||||
gint32 drawable_ID;
|
gint32 drawable_ID;
|
||||||
|
|
||||||
|
@ -123,13 +126,35 @@ file_save (Gimp *gimp,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uri = g_file_get_uri (file);
|
|
||||||
|
|
||||||
if (! file_proc->handles_uri)
|
if (! file_proc->handles_uri)
|
||||||
filename = g_file_get_path (file);
|
{
|
||||||
|
path = g_file_get_path (file);
|
||||||
|
|
||||||
if (! filename)
|
if (! path && g_getenv ("GIMP_HANDLE_REMOTE_FILES"))
|
||||||
filename = g_strdup (uri);
|
{
|
||||||
|
GError *my_error = NULL;
|
||||||
|
|
||||||
|
local_file = file_remote_upload_image_prepare (gimp, file, &mounted,
|
||||||
|
progress, &my_error);
|
||||||
|
|
||||||
|
if (! local_file)
|
||||||
|
{
|
||||||
|
if (my_error)
|
||||||
|
g_propagate_error (error, my_error);
|
||||||
|
else
|
||||||
|
status = GIMP_PDB_CANCEL;
|
||||||
|
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
path = g_file_get_path (local_file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! path)
|
||||||
|
path = g_file_get_uri (file);
|
||||||
|
|
||||||
|
uri = g_file_get_uri (file);
|
||||||
|
|
||||||
/* ref the image, so it can't get deleted during save */
|
/* ref the image, so it can't get deleted during save */
|
||||||
g_object_ref (image);
|
g_object_ref (image);
|
||||||
|
@ -145,7 +170,7 @@ file_save (Gimp *gimp,
|
||||||
GIMP_TYPE_INT32, run_mode,
|
GIMP_TYPE_INT32, run_mode,
|
||||||
GIMP_TYPE_IMAGE_ID, image_ID,
|
GIMP_TYPE_IMAGE_ID, image_ID,
|
||||||
GIMP_TYPE_DRAWABLE_ID, drawable_ID,
|
GIMP_TYPE_DRAWABLE_ID, drawable_ID,
|
||||||
G_TYPE_STRING, filename,
|
G_TYPE_STRING, path,
|
||||||
G_TYPE_STRING, uri,
|
G_TYPE_STRING, uri,
|
||||||
G_TYPE_NONE);
|
G_TYPE_NONE);
|
||||||
|
|
||||||
|
@ -153,6 +178,29 @@ file_save (Gimp *gimp,
|
||||||
|
|
||||||
gimp_value_array_unref (return_vals);
|
gimp_value_array_unref (return_vals);
|
||||||
|
|
||||||
|
if (local_file)
|
||||||
|
{
|
||||||
|
if (status == GIMP_PDB_SUCCESS)
|
||||||
|
{
|
||||||
|
GError *my_error = NULL;
|
||||||
|
|
||||||
|
if (! file_remote_upload_image_finish (gimp, file, local_file,
|
||||||
|
mounted,
|
||||||
|
progress, &my_error))
|
||||||
|
{
|
||||||
|
if (my_error)
|
||||||
|
g_propagate_error (error, my_error);
|
||||||
|
else
|
||||||
|
status = GIMP_PDB_CANCEL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! mounted)
|
||||||
|
g_file_delete (local_file, NULL, NULL);
|
||||||
|
|
||||||
|
g_object_unref (local_file);
|
||||||
|
}
|
||||||
|
|
||||||
if (status == GIMP_PDB_SUCCESS)
|
if (status == GIMP_PDB_SUCCESS)
|
||||||
{
|
{
|
||||||
GimpDocumentList *documents;
|
GimpDocumentList *documents;
|
||||||
|
@ -230,7 +278,7 @@ file_save (Gimp *gimp,
|
||||||
g_object_unref (image);
|
g_object_unref (image);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
g_free (filename);
|
g_free (path);
|
||||||
g_free (uri);
|
g_free (uri);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
|
|
Loading…
Reference in New Issue