mirror of https://github.com/GNOME/gimp.git
app: change file_utils_filename_to_uri() to file_utils_filename_to_file()
This commit is contained in:
parent
3ba0589f14
commit
c884c4f630
|
@ -1856,13 +1856,6 @@ gimp_image_set_file (GimpImage *image,
|
|||
file ? g_file_get_uri (file) : NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_take_uri (GimpImage *image,
|
||||
gchar *uri)
|
||||
{
|
||||
gimp_object_take_name (GIMP_OBJECT (image), uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_image_get_untitled_file:
|
||||
*
|
||||
|
@ -1926,19 +1919,17 @@ void
|
|||
gimp_image_set_filename (GimpImage *image,
|
||||
const gchar *filename)
|
||||
{
|
||||
GFile *file = NULL;
|
||||
|
||||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
|
||||
if (filename && strlen (filename))
|
||||
{
|
||||
gimp_image_take_uri (image,
|
||||
file_utils_filename_to_uri (image->gimp,
|
||||
filename,
|
||||
NULL));
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_image_set_file (image, NULL);
|
||||
}
|
||||
file = file_utils_filename_to_file (image->gimp, filename, NULL);
|
||||
|
||||
gimp_image_set_file (image, file);
|
||||
|
||||
if (file)
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -171,31 +171,21 @@ file_open_location_response (GtkDialog *dialog,
|
|||
if (text && strlen (text))
|
||||
{
|
||||
GimpImage *image;
|
||||
gchar *uri;
|
||||
gchar *filename;
|
||||
gchar *hostname;
|
||||
GFile *file = NULL;
|
||||
GError *error = NULL;
|
||||
GFile *file;
|
||||
GimpPDBStatusType status;
|
||||
GError *error = NULL;
|
||||
|
||||
filename = g_filename_from_uri (text, &hostname, NULL);
|
||||
filename = g_filename_from_uri (text, NULL, NULL);
|
||||
|
||||
if (filename)
|
||||
{
|
||||
uri = g_filename_to_uri (filename, hostname, &error);
|
||||
|
||||
g_free (hostname);
|
||||
file = g_file_new_for_uri (text);
|
||||
g_free (filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
uri = file_utils_filename_to_uri (gimp, text, &error);
|
||||
}
|
||||
|
||||
if (uri)
|
||||
{
|
||||
file = g_file_new_for_uri (uri);
|
||||
g_free (uri);
|
||||
file = file_utils_filename_to_file (gimp, text, &error);
|
||||
}
|
||||
|
||||
box = gimp_progress_box_new ();
|
||||
|
|
|
@ -89,10 +89,10 @@ file_utils_filename_is_uri (const gchar *filename,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
gchar *
|
||||
file_utils_filename_to_uri (Gimp *gimp,
|
||||
const gchar *filename,
|
||||
GError **error)
|
||||
GFile *
|
||||
file_utils_filename_to_file (Gimp *gimp,
|
||||
const gchar *filename,
|
||||
GError **error)
|
||||
{
|
||||
GFile *file;
|
||||
gchar *absolute;
|
||||
|
@ -111,9 +111,7 @@ file_utils_filename_to_uri (Gimp *gimp,
|
|||
{
|
||||
if (g_utf8_validate (filename, -1, NULL))
|
||||
{
|
||||
g_object_unref (file);
|
||||
|
||||
return g_strdup (filename);
|
||||
return file;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -121,15 +119,12 @@ file_utils_filename_to_uri (Gimp *gimp,
|
|||
G_CONVERT_ERROR,
|
||||
G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
|
||||
_("Invalid character sequence in URI"));
|
||||
g_object_unref (file);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else if (file_utils_filename_is_uri (filename, &temp_error))
|
||||
{
|
||||
g_object_unref (file);
|
||||
|
||||
return g_strdup (filename);
|
||||
return file;
|
||||
}
|
||||
else if (temp_error)
|
||||
{
|
||||
|
@ -139,8 +134,6 @@ file_utils_filename_to_uri (Gimp *gimp,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
g_object_unref (file);
|
||||
|
||||
if (! g_path_is_absolute (filename))
|
||||
{
|
||||
gchar *current;
|
||||
|
@ -154,11 +147,11 @@ file_utils_filename_to_uri (Gimp *gimp,
|
|||
absolute = g_strdup (filename);
|
||||
}
|
||||
|
||||
uri = g_filename_to_uri (absolute, NULL, error);
|
||||
file = g_file_new_for_path (absolute);
|
||||
|
||||
g_free (absolute);
|
||||
|
||||
return uri;
|
||||
return file;
|
||||
}
|
||||
|
||||
GFile *
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#define __FILE_UTILS_H__
|
||||
|
||||
|
||||
gchar * file_utils_filename_to_uri (Gimp *gimp,
|
||||
GFile * file_utils_filename_to_file (Gimp *gimp,
|
||||
const gchar *filename,
|
||||
GError **error);
|
||||
|
||||
|
|
|
@ -61,23 +61,19 @@ file_load_invoker (GimpProcedure *procedure,
|
|||
GimpValueArray *return_vals;
|
||||
GimpPlugInProcedure *file_proc;
|
||||
GimpProcedure *proc;
|
||||
gchar *uri;
|
||||
GFile *file;
|
||||
gint i;
|
||||
|
||||
uri = file_utils_filename_to_uri (gimp,
|
||||
g_value_get_string (gimp_value_array_index (args, 1)),
|
||||
error);
|
||||
file = file_utils_filename_to_file (gimp,
|
||||
g_value_get_string (gimp_value_array_index (args, 1)),
|
||||
error);
|
||||
|
||||
if (! uri)
|
||||
if (! file)
|
||||
return gimp_procedure_get_return_values (procedure, FALSE,
|
||||
error ? *error : NULL);
|
||||
|
||||
file = g_file_new_for_uri (uri);
|
||||
g_free (uri);
|
||||
|
||||
file_proc =
|
||||
file_procedure_find (gimp->plug_in_manager->load_procs, file, error);
|
||||
file_proc = file_procedure_find (gimp->plug_in_manager->load_procs,
|
||||
file, error);
|
||||
|
||||
g_object_unref (file);
|
||||
|
||||
|
@ -142,17 +138,13 @@ file_load_layer_invoker (GimpProcedure *procedure,
|
|||
|
||||
if (success)
|
||||
{
|
||||
gchar *uri = file_utils_filename_to_uri (gimp, filename, error);
|
||||
GFile *file = file_utils_filename_to_file (gimp, filename, error);
|
||||
|
||||
if (uri)
|
||||
if (file)
|
||||
{
|
||||
GFile *file;
|
||||
GList *layers;
|
||||
GimpPDBStatusType status;
|
||||
|
||||
file = g_file_new_for_uri (uri);
|
||||
g_free (uri);
|
||||
|
||||
layers = file_open_layers (gimp, context, progress,
|
||||
image, FALSE,
|
||||
file, run_mode, NULL, &status, error);
|
||||
|
@ -202,17 +194,13 @@ file_load_layers_invoker (GimpProcedure *procedure,
|
|||
|
||||
if (success)
|
||||
{
|
||||
gchar *uri = file_utils_filename_to_uri (gimp, filename, error);
|
||||
GFile *file = file_utils_filename_to_file (gimp, filename, error);
|
||||
|
||||
if (uri)
|
||||
if (file)
|
||||
{
|
||||
GFile *file;
|
||||
GList *layers;
|
||||
GimpPDBStatusType status;
|
||||
|
||||
file = g_file_new_for_uri (uri);
|
||||
g_free (uri);
|
||||
|
||||
layers = file_open_layers (gimp, context, progress,
|
||||
image, FALSE,
|
||||
file, run_mode, NULL, &status, error);
|
||||
|
@ -266,27 +254,23 @@ file_save_invoker (GimpProcedure *procedure,
|
|||
GimpValueArray *return_vals;
|
||||
GimpPlugInProcedure *file_proc;
|
||||
GimpProcedure *proc;
|
||||
gchar *uri;
|
||||
GFile *file;
|
||||
gint i;
|
||||
|
||||
uri = file_utils_filename_to_uri (gimp,
|
||||
g_value_get_string (gimp_value_array_index (args, 3)),
|
||||
error);
|
||||
file = file_utils_filename_to_file (gimp,
|
||||
g_value_get_string (gimp_value_array_index (args, 3)),
|
||||
error);
|
||||
|
||||
if (! uri)
|
||||
if (! file)
|
||||
return gimp_procedure_get_return_values (procedure, FALSE,
|
||||
error ? *error : NULL);
|
||||
|
||||
file = g_file_new_for_uri (uri);
|
||||
g_free (uri);
|
||||
|
||||
file_proc =
|
||||
file_procedure_find (gimp->plug_in_manager->save_procs, file, NULL);
|
||||
file_proc = file_procedure_find (gimp->plug_in_manager->save_procs,
|
||||
file, NULL);
|
||||
|
||||
if (! file_proc)
|
||||
file_proc = file_procedure_find (gimp->plug_in_manager->export_procs, file,
|
||||
error);
|
||||
file_proc = file_procedure_find (gimp->plug_in_manager->export_procs,
|
||||
file, error);
|
||||
|
||||
g_object_unref (file);
|
||||
|
||||
|
|
|
@ -54,23 +54,19 @@ HELP
|
|||
GimpValueArray *return_vals;
|
||||
GimpPlugInProcedure *file_proc;
|
||||
GimpProcedure *proc;
|
||||
gchar *uri;
|
||||
GFile *file;
|
||||
gint i;
|
||||
|
||||
uri = file_utils_filename_to_uri (gimp,
|
||||
g_value_get_string (gimp_value_array_index (args, 1)),
|
||||
error);
|
||||
file = file_utils_filename_to_file (gimp,
|
||||
g_value_get_string (gimp_value_array_index (args, 1)),
|
||||
error);
|
||||
|
||||
if (! uri)
|
||||
if (! file)
|
||||
return gimp_procedure_get_return_values (procedure, FALSE,
|
||||
error ? *error : NULL);
|
||||
|
||||
file = g_file_new_for_uri (uri);
|
||||
g_free (uri);
|
||||
|
||||
file_proc =
|
||||
file_procedure_find (gimp->plug_in_manager->load_procs, file, error);
|
||||
file_proc = file_procedure_find (gimp->plug_in_manager->load_procs,
|
||||
file, error);
|
||||
|
||||
g_object_unref (file);
|
||||
|
||||
|
@ -146,17 +142,13 @@ HELP
|
|||
%invoke = (
|
||||
code => <<'CODE'
|
||||
{
|
||||
gchar *uri = file_utils_filename_to_uri (gimp, filename, error);
|
||||
GFile *file = file_utils_filename_to_file (gimp, filename, error);
|
||||
|
||||
if (uri)
|
||||
if (file)
|
||||
{
|
||||
GFile *file;
|
||||
GList *layers;
|
||||
GimpPDBStatusType status;
|
||||
|
||||
file = g_file_new_for_uri (uri);
|
||||
g_free (uri);
|
||||
|
||||
layers = file_open_layers (gimp, context, progress,
|
||||
image, FALSE,
|
||||
file, run_mode, NULL, &status, error);
|
||||
|
@ -209,17 +201,13 @@ HELP
|
|||
%invoke = (
|
||||
code => <<'CODE'
|
||||
{
|
||||
gchar *uri = file_utils_filename_to_uri (gimp, filename, error);
|
||||
GFile *file = file_utils_filename_to_file (gimp, filename, error);
|
||||
|
||||
if (uri)
|
||||
if (file)
|
||||
{
|
||||
GFile *file;
|
||||
GList *layers;
|
||||
GimpPDBStatusType status;
|
||||
|
||||
file = g_file_new_for_uri (uri);
|
||||
g_free (uri);
|
||||
|
||||
layers = file_open_layers (gimp, context, progress,
|
||||
image, FALSE,
|
||||
file, run_mode, NULL, &status, error);
|
||||
|
@ -288,27 +276,23 @@ HELP
|
|||
GimpValueArray *return_vals;
|
||||
GimpPlugInProcedure *file_proc;
|
||||
GimpProcedure *proc;
|
||||
gchar *uri;
|
||||
GFile *file;
|
||||
gint i;
|
||||
|
||||
uri = file_utils_filename_to_uri (gimp,
|
||||
g_value_get_string (gimp_value_array_index (args, 3)),
|
||||
error);
|
||||
file = file_utils_filename_to_file (gimp,
|
||||
g_value_get_string (gimp_value_array_index (args, 3)),
|
||||
error);
|
||||
|
||||
if (! uri)
|
||||
if (! file)
|
||||
return gimp_procedure_get_return_values (procedure, FALSE,
|
||||
error ? *error : NULL);
|
||||
|
||||
file = g_file_new_for_uri (uri);
|
||||
g_free (uri);
|
||||
|
||||
file_proc =
|
||||
file_procedure_find (gimp->plug_in_manager->save_procs, file, NULL);
|
||||
file_proc = file_procedure_find (gimp->plug_in_manager->save_procs,
|
||||
file, NULL);
|
||||
|
||||
if (! file_proc)
|
||||
file_proc = file_procedure_find (gimp->plug_in_manager->export_procs, file,
|
||||
error);
|
||||
file_proc = file_procedure_find (gimp->plug_in_manager->export_procs,
|
||||
file, error);
|
||||
|
||||
g_object_unref (file);
|
||||
|
||||
|
|
Loading…
Reference in New Issue