mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-10-06 09:32:41 +02:00
app: change the image's various URIs to GFiles
which gets rid of a lot of temporarily added GFile code again because we don't need to convert between URI and GFile any longer.
This commit is contained in:
@@ -340,7 +340,7 @@ debug_show_image_graph (GimpImage *source_image)
|
||||
GIMP_RGB,
|
||||
GIMP_PRECISION_U8_GAMMA,
|
||||
FALSE);
|
||||
gimp_image_set_uri (new_image, new_name);
|
||||
gimp_image_set_file (new_image, g_file_new_for_uri (new_name));
|
||||
layer = gimp_layer_new_from_buffer (buffer,
|
||||
new_image,
|
||||
gimp_image_get_layer_format (new_image,
|
||||
|
@@ -256,23 +256,18 @@ file_actions_update (GimpActionGroup *group,
|
||||
Gimp *gimp = action_data_get_gimp (data);
|
||||
GimpImage *image = action_data_get_image (data);
|
||||
GimpDrawable *drawable = NULL;
|
||||
GFile *file = NULL;
|
||||
GFile *source = NULL;
|
||||
GFile *export = NULL;
|
||||
gboolean show_overwrite = FALSE;
|
||||
|
||||
if (image)
|
||||
{
|
||||
const gchar *uri;
|
||||
|
||||
drawable = gimp_image_get_active_drawable (image);
|
||||
|
||||
uri = gimp_image_get_imported_uri (image);
|
||||
if (uri)
|
||||
source = g_file_new_for_uri (uri);
|
||||
|
||||
uri = gimp_image_get_exported_uri (image);
|
||||
if (uri)
|
||||
export = g_file_new_for_uri (uri);
|
||||
file = gimp_image_get_file (image);
|
||||
source = gimp_image_get_imported_file (image);
|
||||
export = gimp_image_get_exported_file (image);
|
||||
}
|
||||
|
||||
show_overwrite =
|
||||
@@ -289,7 +284,7 @@ file_actions_update (GimpActionGroup *group,
|
||||
SET_SENSITIVE ("file-save-as", drawable);
|
||||
SET_SENSITIVE ("file-save-a-copy", drawable);
|
||||
SET_SENSITIVE ("file-save-and-close", drawable);
|
||||
SET_SENSITIVE ("file-revert", image && (gimp_image_get_uri (image) || source));
|
||||
SET_SENSITIVE ("file-revert", image && (file || source));
|
||||
SET_SENSITIVE ("file-export", drawable);
|
||||
SET_VISIBLE ("file-export", ! show_overwrite);
|
||||
SET_SENSITIVE ("file-overwrite", show_overwrite);
|
||||
|
@@ -226,7 +226,6 @@ file_save_cmd_callback (GtkAction *action,
|
||||
GimpImage *image;
|
||||
GtkWidget *widget;
|
||||
GimpSaveMode save_mode;
|
||||
const gchar *uri;
|
||||
GFile *file = NULL;
|
||||
gboolean saved = FALSE;
|
||||
return_if_no_gimp (gimp, data);
|
||||
@@ -240,10 +239,7 @@ file_save_cmd_callback (GtkAction *action,
|
||||
if (! gimp_image_get_active_drawable (image))
|
||||
return;
|
||||
|
||||
uri = gimp_image_get_uri (image);
|
||||
|
||||
if (uri)
|
||||
file = g_file_new_for_uri (uri);
|
||||
file = gimp_image_get_file (image);
|
||||
|
||||
switch (save_mode)
|
||||
{
|
||||
@@ -303,17 +299,16 @@ file_save_cmd_callback (GtkAction *action,
|
||||
case GIMP_SAVE_MODE_EXPORT:
|
||||
case GIMP_SAVE_MODE_OVERWRITE:
|
||||
{
|
||||
const gchar *uri = NULL;
|
||||
GFile *file = NULL;
|
||||
GimpPlugInProcedure *export_proc = NULL;
|
||||
gboolean overwrite = FALSE;
|
||||
|
||||
if (save_mode == GIMP_SAVE_MODE_EXPORT)
|
||||
{
|
||||
uri = gimp_image_get_exported_uri (image);
|
||||
file = gimp_image_get_exported_file (image);
|
||||
export_proc = gimp_image_get_export_proc (image);
|
||||
|
||||
if (! uri)
|
||||
if (! file)
|
||||
{
|
||||
/* Behave as if Export As... was invoked */
|
||||
file_export_dialog_show (gimp, image, widget);
|
||||
@@ -324,14 +319,11 @@ file_save_cmd_callback (GtkAction *action,
|
||||
}
|
||||
else if (save_mode == GIMP_SAVE_MODE_OVERWRITE)
|
||||
{
|
||||
uri = gimp_image_get_imported_uri (image);
|
||||
file = gimp_image_get_imported_file (image);
|
||||
|
||||
overwrite = TRUE;
|
||||
}
|
||||
|
||||
if (uri)
|
||||
file = g_file_new_for_uri (uri);
|
||||
|
||||
if (file && ! export_proc)
|
||||
{
|
||||
export_proc =
|
||||
@@ -349,9 +341,6 @@ file_save_cmd_callback (GtkAction *action,
|
||||
overwrite, ! overwrite,
|
||||
TRUE);
|
||||
}
|
||||
|
||||
if (file)
|
||||
g_object_unref (file);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -393,19 +382,19 @@ file_revert_cmd_callback (GtkAction *action,
|
||||
GimpDisplay *display;
|
||||
GimpImage *image;
|
||||
GtkWidget *dialog;
|
||||
const gchar *uri;
|
||||
GFile *file;
|
||||
return_if_no_display (display, data);
|
||||
|
||||
image = gimp_display_get_image (display);
|
||||
|
||||
uri = gimp_image_get_uri (image);
|
||||
file = gimp_image_get_file (image);
|
||||
|
||||
if (! uri)
|
||||
uri = gimp_image_get_imported_uri (image);
|
||||
if (! file)
|
||||
file = gimp_image_get_imported_file (image);
|
||||
|
||||
dialog = g_object_get_data (G_OBJECT (image), REVERT_DATA_KEY);
|
||||
|
||||
if (! uri)
|
||||
if (! file)
|
||||
{
|
||||
gimp_message_literal (image->gimp,
|
||||
G_OBJECT (display), GIMP_MESSAGE_ERROR,
|
||||
@@ -418,8 +407,6 @@ file_revert_cmd_callback (GtkAction *action,
|
||||
}
|
||||
else
|
||||
{
|
||||
gchar *filename;
|
||||
|
||||
dialog =
|
||||
gimp_message_dialog_new (_("Revert Image"), "document-revert",
|
||||
GTK_WIDGET (gimp_display_get_shell (display)),
|
||||
@@ -444,13 +431,10 @@ file_revert_cmd_callback (GtkAction *action,
|
||||
G_CALLBACK (file_revert_confirm_response),
|
||||
display);
|
||||
|
||||
filename = file_utils_uri_display_name (uri);
|
||||
|
||||
gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box,
|
||||
_("Revert '%s' to '%s'?"),
|
||||
gimp_image_get_display_name (image),
|
||||
filename);
|
||||
g_free (filename);
|
||||
gimp_file_get_utf8_name (file));
|
||||
|
||||
gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box,
|
||||
_("By reverting the image to the state saved "
|
||||
@@ -531,19 +515,11 @@ file_open_dialog_show (Gimp *gimp,
|
||||
if (dialog)
|
||||
{
|
||||
if (! file && image)
|
||||
{
|
||||
const gchar *uri = gimp_image_get_uri (image);
|
||||
if (uri)
|
||||
file = g_file_new_for_uri (uri);
|
||||
}
|
||||
file = gimp_image_get_file (image);
|
||||
|
||||
if (! file)
|
||||
{
|
||||
file = g_object_get_data (G_OBJECT (gimp),
|
||||
GIMP_FILE_OPEN_LAST_FILE_KEY);
|
||||
if (file)
|
||||
g_object_ref (file);
|
||||
}
|
||||
file = g_object_get_data (G_OBJECT (gimp),
|
||||
GIMP_FILE_OPEN_LAST_FILE_KEY);
|
||||
|
||||
if (file)
|
||||
gtk_file_chooser_set_file (GTK_FILE_CHOOSER (dialog), file, NULL);
|
||||
@@ -559,9 +535,6 @@ file_open_dialog_show (Gimp *gimp,
|
||||
|
||||
gtk_window_present (GTK_WINDOW (dialog));
|
||||
}
|
||||
|
||||
if (file)
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
@@ -780,17 +753,14 @@ file_revert_confirm_response (GtkWidget *dialog,
|
||||
{
|
||||
Gimp *gimp = old_image->gimp;
|
||||
GimpImage *new_image;
|
||||
const gchar *uri;
|
||||
GFile *file;
|
||||
GimpPDBStatusType status;
|
||||
GError *error = NULL;
|
||||
|
||||
uri = gimp_image_get_uri (old_image);
|
||||
file = gimp_image_get_file (old_image);
|
||||
|
||||
if (! uri)
|
||||
uri = gimp_image_get_imported_uri (old_image);
|
||||
|
||||
file = g_file_new_for_uri (uri);
|
||||
if (! file)
|
||||
file = gimp_image_get_imported_file (old_image);
|
||||
|
||||
new_image = file_open_image (gimp, gimp_get_user_context (gimp),
|
||||
GIMP_PROGRESS (display),
|
||||
@@ -813,7 +783,5 @@ file_revert_confirm_response (GtkWidget *dialog,
|
||||
gimp_file_get_utf8_name (file), error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
g_object_unref (file);
|
||||
}
|
||||
}
|
||||
|
@@ -46,38 +46,38 @@
|
||||
#include "vectors/gimpvectors.h"
|
||||
|
||||
|
||||
static void gimp_image_duplicate_resolution (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
static void gimp_image_duplicate_save_source_uri (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
static void gimp_image_duplicate_colormap (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
static GimpItem * gimp_image_duplicate_item (GimpItem *item,
|
||||
GimpImage *new_image);
|
||||
static GimpLayer * gimp_image_duplicate_layers (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
static GimpChannel * gimp_image_duplicate_channels (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
static GimpVectors * gimp_image_duplicate_vectors (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
static void gimp_image_duplicate_floating_sel (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
static void gimp_image_duplicate_mask (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
static void gimp_image_duplicate_components (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
static void gimp_image_duplicate_guides (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
static void gimp_image_duplicate_sample_points (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
static void gimp_image_duplicate_grid (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
static void gimp_image_duplicate_metadata (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
static void gimp_image_duplicate_quick_mask (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
static void gimp_image_duplicate_parasites (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
static void gimp_image_duplicate_resolution (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
static void gimp_image_duplicate_save_source_file (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
static void gimp_image_duplicate_colormap (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
static GimpItem * gimp_image_duplicate_item (GimpItem *item,
|
||||
GimpImage *new_image);
|
||||
static GimpLayer * gimp_image_duplicate_layers (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
static GimpChannel * gimp_image_duplicate_channels (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
static GimpVectors * gimp_image_duplicate_vectors (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
static void gimp_image_duplicate_floating_sel (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
static void gimp_image_duplicate_mask (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
static void gimp_image_duplicate_components (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
static void gimp_image_duplicate_guides (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
static void gimp_image_duplicate_sample_points (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
static void gimp_image_duplicate_grid (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
static void gimp_image_duplicate_metadata (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
static void gimp_image_duplicate_quick_mask (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
static void gimp_image_duplicate_parasites (GimpImage *image,
|
||||
GimpImage *new_image);
|
||||
|
||||
|
||||
GimpImage *
|
||||
@@ -102,8 +102,7 @@ gimp_image_duplicate (GimpImage *image)
|
||||
gimp_image_undo_disable (new_image);
|
||||
|
||||
/* Store the source uri to be used by the save dialog */
|
||||
gimp_image_duplicate_save_source_uri (image, new_image);
|
||||
|
||||
gimp_image_duplicate_save_source_file (image, new_image);
|
||||
|
||||
/* Copy the colormap if necessary */
|
||||
gimp_image_duplicate_colormap (image, new_image);
|
||||
@@ -175,12 +174,15 @@ gimp_image_duplicate_resolution (GimpImage *image,
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_duplicate_save_source_uri (GimpImage *image,
|
||||
GimpImage *new_image)
|
||||
gimp_image_duplicate_save_source_file (GimpImage *image,
|
||||
GimpImage *new_image)
|
||||
{
|
||||
g_object_set_data_full (G_OBJECT (new_image), "gimp-image-source-uri",
|
||||
g_strdup (gimp_image_get_uri (image)),
|
||||
(GDestroyNotify) g_free);
|
||||
GFile *file = gimp_image_get_file (image);
|
||||
|
||||
if (file)
|
||||
g_object_set_data_full (G_OBJECT (new_image), "gimp-image-source-file",
|
||||
g_object_ref (file),
|
||||
(GDestroyNotify) g_object_unref);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -86,11 +86,6 @@
|
||||
#define TRC(x)
|
||||
#endif
|
||||
|
||||
/* Data keys for GimpImage */
|
||||
#define GIMP_FILE_EXPORT_URI_KEY "gimp-file-export-uri"
|
||||
#define GIMP_FILE_SAVE_A_COPY_URI_KEY "gimp-file-save-a-copy-uri"
|
||||
#define GIMP_FILE_IMPORT_SOURCE_URI_KEY "gimp-file-import-source-uri"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -419,9 +414,9 @@ gimp_image_class_init (GimpImageClass *klass)
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpImageClass, saved),
|
||||
NULL, NULL,
|
||||
gimp_marshal_VOID__STRING,
|
||||
gimp_marshal_VOID__OBJECT,
|
||||
G_TYPE_NONE, 1,
|
||||
G_TYPE_STRING);
|
||||
G_TYPE_FILE);
|
||||
|
||||
gimp_image_signals[EXPORTED] =
|
||||
g_signal_new ("exported",
|
||||
@@ -429,9 +424,9 @@ gimp_image_class_init (GimpImageClass *klass)
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpImageClass, exported),
|
||||
NULL, NULL,
|
||||
gimp_marshal_VOID__STRING,
|
||||
gimp_marshal_VOID__OBJECT,
|
||||
G_TYPE_NONE, 1,
|
||||
G_TYPE_STRING);
|
||||
G_TYPE_FILE);
|
||||
|
||||
gimp_image_signals[GUIDE_ADDED] =
|
||||
g_signal_new ("guide-added",
|
||||
@@ -1086,7 +1081,19 @@ gimp_image_name_changed (GimpObject *object)
|
||||
*/
|
||||
name = gimp_object_get_name (object);
|
||||
if (name && strlen (name) == 0)
|
||||
gimp_object_name_free (object);
|
||||
{
|
||||
gimp_object_name_free (object);
|
||||
name = NULL;
|
||||
}
|
||||
|
||||
if (private->file)
|
||||
{
|
||||
g_object_unref (private->file);
|
||||
private->file = NULL;
|
||||
}
|
||||
|
||||
if (name)
|
||||
private->file = g_file_new_for_uri (name);
|
||||
}
|
||||
|
||||
static gint64
|
||||
@@ -1809,12 +1816,22 @@ gimp_image_get_by_ID (Gimp *gimp,
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_set_uri (GimpImage *image,
|
||||
const gchar *uri)
|
||||
gimp_image_set_file (GimpImage *image,
|
||||
GFile *file)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
g_return_if_fail (file == NULL || G_IS_FILE (file));
|
||||
|
||||
gimp_object_set_name (GIMP_OBJECT (image), uri);
|
||||
if (file)
|
||||
{
|
||||
gchar *uri = g_file_get_uri (file);
|
||||
gimp_object_set_name (GIMP_OBJECT (image), uri);
|
||||
g_free (uri);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_object_set_name (GIMP_OBJECT (image), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1851,25 +1868,25 @@ gimp_image_get_uri_or_untitled (const GimpImage *image)
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
|
||||
uri = gimp_image_get_uri (image);
|
||||
uri = gimp_object_get_name (image);
|
||||
|
||||
return uri ? uri : gimp_image_get_string_untitled ();
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_image_get_uri:
|
||||
* gimp_image_get_file:
|
||||
* @image: A #GimpImage.
|
||||
*
|
||||
* Get the URI of the XCF image, or NULL if there is no URI.
|
||||
* Get the file of the XCF image, or NULL if there is no file.
|
||||
*
|
||||
* Returns: The URI, or NULL.
|
||||
* Returns: The file, or NULL.
|
||||
**/
|
||||
const gchar *
|
||||
gimp_image_get_uri (const GimpImage *image)
|
||||
GFile *
|
||||
gimp_image_get_file (const GimpImage *image)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
|
||||
return gimp_object_get_name (image);
|
||||
return GIMP_IMAGE_GET_PRIVATE (image)->file;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1887,132 +1904,148 @@ gimp_image_set_filename (GimpImage *image,
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_image_set_uri (image, NULL);
|
||||
gimp_image_set_file (image, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_image_get_imported_uri:
|
||||
* gimp_image_get_imported_file:
|
||||
* @image: A #GimpImage.
|
||||
*
|
||||
* Returns: The URI of the imported image, or NULL if the image has
|
||||
* Returns: The file of the imported image, or NULL if the image has
|
||||
* been saved as XCF after it was imported.
|
||||
**/
|
||||
const gchar *
|
||||
gimp_image_get_imported_uri (const GimpImage *image)
|
||||
GFile *
|
||||
gimp_image_get_imported_file (const GimpImage *image)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
|
||||
return g_object_get_data (G_OBJECT (image),
|
||||
GIMP_FILE_IMPORT_SOURCE_URI_KEY);
|
||||
return GIMP_IMAGE_GET_PRIVATE (image)->imported_file;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_image_get_exported_uri:
|
||||
* gimp_image_get_exported_file:
|
||||
* @image: A #GimpImage.
|
||||
*
|
||||
* Returns: The URI of the image last exported from this XCF file, or
|
||||
* Returns: The file of the image last exported from this XCF file, or
|
||||
* NULL if the image has never been exported.
|
||||
**/
|
||||
const gchar *
|
||||
gimp_image_get_exported_uri (const GimpImage *image)
|
||||
GFile *
|
||||
gimp_image_get_exported_file (const GimpImage *image)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
|
||||
return g_object_get_data (G_OBJECT (image),
|
||||
GIMP_FILE_EXPORT_URI_KEY);
|
||||
return GIMP_IMAGE_GET_PRIVATE (image)->exported_file;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_image_get_save_a_copy_uri:
|
||||
* gimp_image_get_save_a_copy_file:
|
||||
* @image: A #GimpImage.
|
||||
*
|
||||
* Returns: The URI of the last copy that was saved of this XCF file.
|
||||
**/
|
||||
const gchar *
|
||||
gimp_image_get_save_a_copy_uri (const GimpImage *image)
|
||||
GFile *
|
||||
gimp_image_get_save_a_copy_file (const GimpImage *image)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
|
||||
return g_object_get_data (G_OBJECT (image),
|
||||
GIMP_FILE_SAVE_A_COPY_URI_KEY);
|
||||
return GIMP_IMAGE_GET_PRIVATE (image)->save_a_copy_file;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_image_get_any_uri:
|
||||
* gimp_image_get_any_file:
|
||||
* @image: A #GimpImage.
|
||||
*
|
||||
* Returns: The XCF file URI, the imported file URI, or the exported
|
||||
* file URI, in that order of precedence.
|
||||
* Returns: The XCF file, the imported file, or the exported file, in
|
||||
* that order of precedence.
|
||||
**/
|
||||
const gchar *
|
||||
gimp_image_get_any_uri (const GimpImage *image)
|
||||
GFile *
|
||||
gimp_image_get_any_file (const GimpImage *image)
|
||||
{
|
||||
const gchar *uri;
|
||||
GFile *file;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
|
||||
uri = gimp_image_get_uri (image);
|
||||
if (! uri)
|
||||
file = gimp_image_get_file (image);
|
||||
if (! file)
|
||||
{
|
||||
uri = gimp_image_get_imported_uri (image);
|
||||
if (! uri)
|
||||
file = gimp_image_get_imported_file (image);
|
||||
if (! file)
|
||||
{
|
||||
uri = gimp_image_get_exported_uri (image);
|
||||
file = gimp_image_get_exported_file (image);
|
||||
}
|
||||
}
|
||||
|
||||
return uri;
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_image_set_imported_uri:
|
||||
* @image: A #GimpImage.
|
||||
* @uri:
|
||||
* @file:
|
||||
*
|
||||
* Sets the URI this file was imported from.
|
||||
**/
|
||||
void
|
||||
gimp_image_set_imported_uri (GimpImage *image,
|
||||
const gchar *uri)
|
||||
gimp_image_set_imported_file (GimpImage *image,
|
||||
GFile *file)
|
||||
{
|
||||
GimpImagePrivate *private;
|
||||
|
||||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
g_return_if_fail (file == NULL || G_IS_FILE (file));
|
||||
|
||||
if (gimp_image_get_imported_uri (image) == uri)
|
||||
return;
|
||||
private = GIMP_IMAGE_GET_PRIVATE (image);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (image), GIMP_FILE_IMPORT_SOURCE_URI_KEY,
|
||||
g_strdup (uri), (GDestroyNotify) g_free);
|
||||
if (private->imported_file != file)
|
||||
{
|
||||
if (private->imported_file)
|
||||
g_object_unref (private->imported_file);
|
||||
|
||||
gimp_object_name_changed (GIMP_OBJECT (image));
|
||||
private->imported_file = file;
|
||||
|
||||
if (private->imported_file)
|
||||
g_object_ref (private->imported_file);
|
||||
|
||||
gimp_object_name_changed (GIMP_OBJECT (image));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_image_set_exported_uri:
|
||||
* gimp_image_set_exported_file:
|
||||
* @image: A #GimpImage.
|
||||
* @uri:
|
||||
* @file:
|
||||
*
|
||||
* Sets the URI this file was last exported to. Note that saving as
|
||||
* Sets the file this image was last exported to. Note that saving as
|
||||
* XCF is not "exporting".
|
||||
**/
|
||||
void
|
||||
gimp_image_set_exported_uri (GimpImage *image,
|
||||
const gchar *uri)
|
||||
gimp_image_set_exported_file (GimpImage *image,
|
||||
GFile *file)
|
||||
{
|
||||
GimpImagePrivate *private;
|
||||
|
||||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
g_return_if_fail (file == NULL || G_IS_FILE (file));
|
||||
|
||||
if (gimp_image_get_exported_uri (image) == uri)
|
||||
return;
|
||||
private = GIMP_IMAGE_GET_PRIVATE (image);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (image),
|
||||
GIMP_FILE_EXPORT_URI_KEY,
|
||||
g_strdup (uri), (GDestroyNotify) g_free);
|
||||
if (private->exported_file != file)
|
||||
{
|
||||
if (private->exported_file)
|
||||
g_object_unref (private->exported_file);
|
||||
|
||||
gimp_object_name_changed (GIMP_OBJECT (image));
|
||||
private->exported_file = file;
|
||||
|
||||
if (private->exported_file)
|
||||
g_object_ref (private->exported_file);
|
||||
|
||||
gimp_object_name_changed (GIMP_OBJECT (image));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_image_set_save_a_copy_uri:
|
||||
* gimp_image_set_save_a_copy_file:
|
||||
* @image: A #GimpImage.
|
||||
* @uri:
|
||||
*
|
||||
@@ -2020,32 +2053,41 @@ gimp_image_set_exported_uri (GimpImage *image,
|
||||
* "save a copy" action.
|
||||
**/
|
||||
void
|
||||
gimp_image_set_save_a_copy_uri (GimpImage *image,
|
||||
const gchar *uri)
|
||||
gimp_image_set_save_a_copy_file (GimpImage *image,
|
||||
GFile *file)
|
||||
{
|
||||
GimpImagePrivate *private;
|
||||
|
||||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
g_return_if_fail (file == NULL || G_IS_FILE (file));
|
||||
|
||||
if (gimp_image_get_save_a_copy_uri (image) == uri)
|
||||
return;
|
||||
private = GIMP_IMAGE_GET_PRIVATE (image);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (image),
|
||||
GIMP_FILE_SAVE_A_COPY_URI_KEY,
|
||||
g_strdup (uri), (GDestroyNotify) g_free);
|
||||
if (private->save_a_copy_file != file)
|
||||
{
|
||||
if (private->save_a_copy_file)
|
||||
g_object_unref (private->save_a_copy_file);
|
||||
|
||||
private->save_a_copy_file = file;
|
||||
|
||||
if (private->save_a_copy_file)
|
||||
g_object_ref (private->save_a_copy_file);
|
||||
}
|
||||
}
|
||||
|
||||
gchar *
|
||||
gimp_image_get_filename (const GimpImage *image)
|
||||
{
|
||||
const gchar *uri;
|
||||
GFile *file;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
|
||||
uri = gimp_image_get_uri (image);
|
||||
file = gimp_image_get_file (image);
|
||||
|
||||
if (! uri)
|
||||
if (! file)
|
||||
return NULL;
|
||||
|
||||
return g_filename_from_uri (uri, NULL, NULL);
|
||||
return g_file_get_path (file);
|
||||
}
|
||||
|
||||
static gchar *
|
||||
@@ -2054,9 +2096,10 @@ gimp_image_format_display_uri (GimpImage *image,
|
||||
{
|
||||
const gchar *uri_format = NULL;
|
||||
const gchar *export_status = NULL;
|
||||
const gchar *uri;
|
||||
const gchar *source;
|
||||
const gchar *dest;
|
||||
GFile *file = NULL;
|
||||
GFile *source = NULL;
|
||||
GFile *dest = NULL;
|
||||
GFile *display_file = NULL;
|
||||
gboolean is_imported;
|
||||
gboolean is_exported;
|
||||
gchar *display_uri = NULL;
|
||||
@@ -2065,29 +2108,29 @@ gimp_image_format_display_uri (GimpImage *image,
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
|
||||
uri = gimp_image_get_uri (image);
|
||||
source = gimp_image_get_imported_uri (image);
|
||||
dest = gimp_image_get_exported_uri (image);
|
||||
file = gimp_image_get_file (image);
|
||||
source = gimp_image_get_imported_file (image);
|
||||
dest = gimp_image_get_exported_file (image);
|
||||
|
||||
is_imported = (source != NULL);
|
||||
is_exported = (dest != NULL);
|
||||
|
||||
if (uri)
|
||||
if (file)
|
||||
{
|
||||
display_uri = g_strdup (uri);
|
||||
uri_format = "%s";
|
||||
display_file = g_object_ref (file);
|
||||
uri_format = "%s";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_imported)
|
||||
display_uri = g_strdup (source);
|
||||
display_file = source;
|
||||
|
||||
/* Calculate filename suffix */
|
||||
if (! gimp_image_is_export_dirty (image))
|
||||
{
|
||||
if (is_exported)
|
||||
{
|
||||
display_uri = g_strdup (dest);
|
||||
display_file = dest;
|
||||
export_status = _(" (exported)");
|
||||
}
|
||||
else if (is_imported)
|
||||
@@ -2104,32 +2147,21 @@ gimp_image_format_display_uri (GimpImage *image,
|
||||
export_status = _(" (imported)");
|
||||
}
|
||||
|
||||
if (display_uri)
|
||||
{
|
||||
gchar *tmp = file_utils_uri_with_new_ext (display_uri, NULL);
|
||||
g_free (display_uri);
|
||||
display_uri = tmp;
|
||||
}
|
||||
if (display_file)
|
||||
display_file = file_utils_file_with_new_ext (display_file, NULL);
|
||||
|
||||
uri_format = "[%s]";
|
||||
}
|
||||
|
||||
if (! display_uri)
|
||||
{
|
||||
display_uri = g_strdup (gimp_image_get_string_untitled ());
|
||||
}
|
||||
else if (basename)
|
||||
{
|
||||
tmp = file_utils_uri_display_basename (display_uri);
|
||||
g_free (display_uri);
|
||||
display_uri = tmp;
|
||||
}
|
||||
if (! display_file)
|
||||
display_file = g_file_new_for_uri (gimp_image_get_string_untitled ());
|
||||
|
||||
if (basename)
|
||||
display_uri = g_path_get_basename (gimp_file_get_utf8_name (display_file));
|
||||
else
|
||||
{
|
||||
tmp = file_utils_uri_display_name (display_uri);
|
||||
g_free (display_uri);
|
||||
display_uri = tmp;
|
||||
}
|
||||
display_uri = g_strdup (gimp_file_get_utf8_name (display_file));
|
||||
|
||||
g_object_unref (display_file);
|
||||
|
||||
format_string = g_strconcat (uri_format, export_status, NULL);
|
||||
|
||||
@@ -3015,37 +3047,37 @@ gimp_image_get_dirty_time (const GimpImage *image)
|
||||
/**
|
||||
* gimp_image_saved:
|
||||
* @image:
|
||||
* @uri:
|
||||
* @file:
|
||||
*
|
||||
* Emits the "saved" signal, indicating that @image was saved to the
|
||||
* location specified by @uri.
|
||||
* location specified by @file.
|
||||
*/
|
||||
void
|
||||
gimp_image_saved (GimpImage *image,
|
||||
const gchar *uri)
|
||||
gimp_image_saved (GimpImage *image,
|
||||
GFile *file)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
g_return_if_fail (uri != NULL);
|
||||
g_return_if_fail (G_IS_FILE (file));
|
||||
|
||||
g_signal_emit (image, gimp_image_signals[SAVED], 0, uri);
|
||||
g_signal_emit (image, gimp_image_signals[SAVED], 0, file);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_image_exported:
|
||||
* @image:
|
||||
* @uri:
|
||||
* @file:
|
||||
*
|
||||
* Emits the "exported" signal, indicating that @image was exported to the
|
||||
* location specified by @uri.
|
||||
* location specified by @file.
|
||||
*/
|
||||
void
|
||||
gimp_image_exported (GimpImage *image,
|
||||
const gchar *uri)
|
||||
gimp_image_exported (GimpImage *image,
|
||||
GFile *file)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
g_return_if_fail (uri != NULL);
|
||||
g_return_if_fail (G_IS_FILE (file));
|
||||
|
||||
g_signal_emit (image, gimp_image_signals[EXPORTED], 0, uri);
|
||||
g_signal_emit (image, gimp_image_signals[EXPORTED], 0, file);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -74,9 +74,9 @@ struct _GimpImageClass
|
||||
void (* dirty) (GimpImage *image,
|
||||
GimpDirtyMask dirty_mask);
|
||||
void (* saved) (GimpImage *image,
|
||||
const gchar *uri);
|
||||
GFile *file);
|
||||
void (* exported) (GimpImage *image,
|
||||
const gchar *uri);
|
||||
GFile *file);
|
||||
|
||||
void (* guide_added) (GimpImage *image,
|
||||
GimpGuide *guide);
|
||||
@@ -132,21 +132,21 @@ gint gimp_image_get_ID (const GimpImage *image);
|
||||
GimpImage * gimp_image_get_by_ID (Gimp *gimp,
|
||||
gint id);
|
||||
|
||||
const gchar * gimp_image_get_uri (const GimpImage *image);
|
||||
GFile * gimp_image_get_file (const GimpImage *image);
|
||||
const gchar * gimp_image_get_uri_or_untitled (const GimpImage *image);
|
||||
const gchar * gimp_image_get_imported_uri (const GimpImage *image);
|
||||
const gchar * gimp_image_get_exported_uri (const GimpImage *image);
|
||||
const gchar * gimp_image_get_save_a_copy_uri (const GimpImage *image);
|
||||
const gchar * gimp_image_get_any_uri (const GimpImage *image);
|
||||
GFile * gimp_image_get_imported_file (const GimpImage *image);
|
||||
GFile * gimp_image_get_exported_file (const GimpImage *image);
|
||||
GFile * gimp_image_get_save_a_copy_file (const GimpImage *image);
|
||||
GFile * gimp_image_get_any_file (const GimpImage *image);
|
||||
|
||||
void gimp_image_set_uri (GimpImage *image,
|
||||
const gchar *uri);
|
||||
void gimp_image_set_imported_uri (GimpImage *image,
|
||||
const gchar *uri);
|
||||
void gimp_image_set_exported_uri (GimpImage *image,
|
||||
const gchar *uri);
|
||||
void gimp_image_set_save_a_copy_uri (GimpImage *image,
|
||||
const gchar *uri);
|
||||
void gimp_image_set_file (GimpImage *image,
|
||||
GFile *file);
|
||||
void gimp_image_set_imported_file (GimpImage *image,
|
||||
GFile *file);
|
||||
void gimp_image_set_exported_file (GimpImage *image,
|
||||
GFile *file);
|
||||
void gimp_image_set_save_a_copy_file (GimpImage *image,
|
||||
GFile *file);
|
||||
|
||||
void gimp_image_set_filename (GimpImage *image,
|
||||
const gchar *filename);
|
||||
@@ -162,12 +162,12 @@ void gimp_image_set_save_proc (GimpImage *image,
|
||||
GimpPlugInProcedure *proc);
|
||||
GimpPlugInProcedure * gimp_image_get_save_proc (const GimpImage *image);
|
||||
void gimp_image_saved (GimpImage *image,
|
||||
const gchar *uri);
|
||||
GFile *file);
|
||||
void gimp_image_set_export_proc (GimpImage *image,
|
||||
GimpPlugInProcedure *proc);
|
||||
GimpPlugInProcedure * gimp_image_get_export_proc (const GimpImage *image);
|
||||
void gimp_image_exported (GimpImage *image,
|
||||
const gchar *uri);
|
||||
GFile *file);
|
||||
|
||||
void gimp_image_set_resolution (GimpImage *image,
|
||||
gdouble xres,
|
||||
|
@@ -214,11 +214,7 @@ file_save_dialog_response (GtkWidget *save_dialog,
|
||||
* file_save()
|
||||
*/
|
||||
if (dialog->save_a_copy)
|
||||
{
|
||||
gchar *uri = g_file_get_uri (file);
|
||||
gimp_image_set_save_a_copy_uri (dialog->image, uri);
|
||||
g_free (uri);
|
||||
}
|
||||
gimp_image_set_save_a_copy_file (dialog->image, file);
|
||||
|
||||
if (! dialog->export)
|
||||
g_object_set_data_full (G_OBJECT (dialog->image->gimp),
|
||||
|
@@ -22,6 +22,7 @@
|
||||
#include <gegl.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "dialogs-types.h"
|
||||
@@ -403,24 +404,22 @@ quit_close_all_dialog_name_cell_func (GtkTreeViewColumn *tree_column,
|
||||
}
|
||||
else
|
||||
{
|
||||
const gchar *uri;
|
||||
gchar *filename;
|
||||
GFile *file;
|
||||
const gchar *filename;
|
||||
gchar *escaped_name;
|
||||
gchar *escaped_filename;
|
||||
gchar *exported;
|
||||
gchar *markup;
|
||||
|
||||
uri = gimp_image_get_exported_uri (image);
|
||||
if (! uri)
|
||||
uri = gimp_image_get_imported_uri (image);
|
||||
file = gimp_image_get_exported_file (image);
|
||||
if (! file)
|
||||
file = gimp_image_get_imported_file (image);
|
||||
|
||||
filename = file_utils_uri_to_utf8_filename (uri);
|
||||
filename = gimp_file_get_utf8_name (file);
|
||||
|
||||
escaped_name = g_markup_escape_text (name, -1);
|
||||
escaped_filename = g_markup_escape_text (filename, -1);
|
||||
|
||||
g_free (filename);
|
||||
|
||||
exported = g_strdup_printf (_("Exported to %s"), escaped_filename);
|
||||
markup = g_strdup_printf ("%s\n<i>%s</i>", escaped_name, exported);
|
||||
g_free (exported);
|
||||
|
@@ -22,6 +22,7 @@
|
||||
#include <gegl.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "display-types.h"
|
||||
@@ -56,7 +57,7 @@ static void gimp_display_shell_close_dialog (GimpDisplayShell *shell,
|
||||
static void gimp_display_shell_close_name_changed (GimpImage *image,
|
||||
GimpMessageBox *box);
|
||||
static void gimp_display_shell_close_exported (GimpImage *image,
|
||||
const gchar *uri,
|
||||
GFile *file,
|
||||
GimpMessageBox *box);
|
||||
static gboolean gimp_display_shell_close_time_changed (GimpMessageBox *box);
|
||||
static void gimp_display_shell_close_response (GtkWidget *widget,
|
||||
@@ -156,7 +157,7 @@ gimp_display_shell_close_dialog (GimpDisplayShell *shell,
|
||||
gchar *accel_string;
|
||||
gchar *hint;
|
||||
gchar *markup;
|
||||
const gchar *uri;
|
||||
GFile *file;
|
||||
|
||||
if (shell->close_dialog)
|
||||
{
|
||||
@@ -164,7 +165,7 @@ gimp_display_shell_close_dialog (GimpDisplayShell *shell,
|
||||
return;
|
||||
}
|
||||
|
||||
uri = gimp_image_get_uri (image);
|
||||
file = gimp_image_get_file (image);
|
||||
|
||||
title = g_strdup_printf (_("Close %s"), gimp_image_get_display_name (image));
|
||||
|
||||
@@ -179,7 +180,7 @@ gimp_display_shell_close_dialog (GimpDisplayShell *shell,
|
||||
gtk_dialog_add_buttons (GTK_DIALOG (dialog),
|
||||
_("_Discard Changes"), GTK_RESPONSE_CLOSE,
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||
(uri ?
|
||||
(file ?
|
||||
GTK_STOCK_SAVE :
|
||||
GTK_STOCK_SAVE_AS), RESPONSE_SAVE,
|
||||
NULL);
|
||||
@@ -281,7 +282,7 @@ gimp_display_shell_close_name_changed (GimpImage *image,
|
||||
|
||||
static void
|
||||
gimp_display_shell_close_exported (GimpImage *image,
|
||||
const gchar *uri,
|
||||
GFile *file,
|
||||
GimpMessageBox *box)
|
||||
{
|
||||
gimp_display_shell_close_time_changed (box);
|
||||
@@ -342,19 +343,14 @@ gimp_display_shell_close_time_changed (GimpMessageBox *box)
|
||||
|
||||
if (! gimp_image_is_export_dirty (image))
|
||||
{
|
||||
const gchar *uri;
|
||||
gchar *filename;
|
||||
GFile *file;
|
||||
|
||||
uri = gimp_image_get_exported_uri (image);
|
||||
if (! uri)
|
||||
uri = gimp_image_get_imported_uri (image);
|
||||
|
||||
filename = file_utils_uri_to_utf8_filename (uri);
|
||||
file = gimp_image_get_exported_file (image);
|
||||
if (! file)
|
||||
file = gimp_image_get_imported_file (image);
|
||||
|
||||
export_text = g_strdup_printf (_("The image has been exported to '%s'."),
|
||||
filename);
|
||||
|
||||
g_free (filename);
|
||||
gimp_file_get_utf8_name (file));
|
||||
}
|
||||
|
||||
if (time_text && export_text)
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#include <gegl.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpmath/gimpmath.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
@@ -43,8 +44,6 @@
|
||||
|
||||
#include "vectors/gimpvectors.h"
|
||||
|
||||
#include "file/file-utils.h"
|
||||
|
||||
#include "widgets/gimpwidgets-utils.h"
|
||||
|
||||
#include "gimpcanvasguide.h"
|
||||
@@ -120,10 +119,10 @@ static void gimp_display_shell_invalidate_preview_handler (GimpImage *i
|
||||
static void gimp_display_shell_profile_changed_handler (GimpColorManaged *image,
|
||||
GimpDisplayShell *shell);
|
||||
static void gimp_display_shell_saved_handler (GimpImage *image,
|
||||
const gchar *uri,
|
||||
GFile *file,
|
||||
GimpDisplayShell *shell);
|
||||
static void gimp_display_shell_exported_handler (GimpImage *image,
|
||||
const gchar *uri,
|
||||
GFile *file,
|
||||
GimpDisplayShell *shell);
|
||||
|
||||
static void gimp_display_shell_active_vectors_handler (GimpImage *image,
|
||||
@@ -786,30 +785,26 @@ gimp_display_shell_profile_changed_handler (GimpColorManaged *image,
|
||||
|
||||
static void
|
||||
gimp_display_shell_saved_handler (GimpImage *image,
|
||||
const gchar *uri,
|
||||
GFile *file,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
GimpStatusbar *statusbar = gimp_display_shell_get_statusbar (shell);
|
||||
gchar *filename = file_utils_uri_display_name (uri);
|
||||
|
||||
gimp_statusbar_push_temp (statusbar, GIMP_MESSAGE_INFO,
|
||||
"document-save", _("Image saved to '%s'"),
|
||||
filename);
|
||||
g_free (filename);
|
||||
gimp_file_get_utf8_name (file));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_display_shell_exported_handler (GimpImage *image,
|
||||
const gchar *uri,
|
||||
GFile *file,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
GimpStatusbar *statusbar = gimp_display_shell_get_statusbar (shell);
|
||||
gchar *filename = file_utils_uri_display_name (uri);
|
||||
|
||||
gimp_statusbar_push_temp (statusbar, GIMP_MESSAGE_INFO,
|
||||
"document-save", _("Image exported to '%s'"),
|
||||
filename);
|
||||
g_free (filename);
|
||||
gimp_file_get_utf8_name (file));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -209,12 +209,10 @@ file_open_image (Gimp *gimp,
|
||||
if (file_open_file_proc_is_import (file_proc))
|
||||
{
|
||||
/* Remember the import source */
|
||||
gchar *uri = g_file_get_uri (file);
|
||||
gimp_image_set_imported_uri (image, uri);
|
||||
g_free (uri);
|
||||
gimp_image_set_imported_file (image, file);
|
||||
|
||||
/* We shall treat this file as an Untitled file */
|
||||
gimp_image_set_uri (image, NULL);
|
||||
gimp_image_set_file (image, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -493,8 +491,7 @@ file_open_with_proc_and_display (Gimp *gimp,
|
||||
{
|
||||
GimpDocumentList *documents = GIMP_DOCUMENT_LIST (gimp->documents);
|
||||
GimpImagefile *imagefile;
|
||||
const gchar *any_uri;
|
||||
gchar *uri;
|
||||
GFile *any_file;
|
||||
|
||||
imagefile = gimp_document_list_add_file (documents, file, mime_type);
|
||||
|
||||
@@ -502,10 +499,9 @@ file_open_with_proc_and_display (Gimp *gimp,
|
||||
* resulting image's uri match. Use any_uri() here so we
|
||||
* create thumbnails for both XCF and imported images.
|
||||
*/
|
||||
any_uri = gimp_image_get_any_uri (image);
|
||||
uri = g_file_get_uri (file);
|
||||
any_file = gimp_image_get_any_file (image);
|
||||
|
||||
if (any_uri && ! strcmp (uri, any_uri))
|
||||
if (any_file && g_file_equal (file, any_file))
|
||||
{
|
||||
/* no need to save a thumbnail if there's a good one already */
|
||||
if (! gimp_imagefile_check_thumbnail (imagefile))
|
||||
@@ -514,8 +510,6 @@ file_open_with_proc_and_display (Gimp *gimp,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
g_free (uri);
|
||||
}
|
||||
|
||||
/* announce that we opened this image */
|
||||
@@ -668,7 +662,7 @@ file_open_sanitize_image (GimpImage *image,
|
||||
gboolean as_new)
|
||||
{
|
||||
if (as_new)
|
||||
gimp_image_set_uri (image, NULL);
|
||||
gimp_image_set_file (image, NULL);
|
||||
|
||||
/* clear all undo steps */
|
||||
gimp_image_undo_free (image);
|
||||
|
@@ -158,14 +158,14 @@ file_save (Gimp *gimp,
|
||||
|
||||
if (change_saved_state)
|
||||
{
|
||||
gimp_image_set_uri (image, uri);
|
||||
gimp_image_set_file (image, file);
|
||||
gimp_image_set_save_proc (image, file_proc);
|
||||
|
||||
/* Forget the import source when we save. We interpret a
|
||||
* save as that the user is not interested in being able
|
||||
* to quickly export back to the original any longer
|
||||
*/
|
||||
gimp_image_set_imported_uri (image, NULL);
|
||||
gimp_image_set_imported_file (image, NULL);
|
||||
|
||||
gimp_image_clean_all (image);
|
||||
}
|
||||
@@ -186,22 +186,22 @@ file_save (Gimp *gimp,
|
||||
* happens implicitly when saving since the GimpObject name
|
||||
* of a GimpImage is the last-save URI
|
||||
*/
|
||||
gimp_image_set_exported_uri (image, uri);
|
||||
gimp_image_set_exported_file (image, file);
|
||||
gimp_image_set_export_proc (image, file_proc);
|
||||
|
||||
/* An image can not be considered both exported and imported
|
||||
* at the same time, so stop consider it as imported now
|
||||
* that we consider it exported.
|
||||
*/
|
||||
gimp_image_set_imported_uri (image, NULL);
|
||||
gimp_image_set_imported_file (image, NULL);
|
||||
|
||||
gimp_image_export_clean_all (image);
|
||||
}
|
||||
|
||||
if (export_backward || export_forward)
|
||||
gimp_image_exported (image, uri);
|
||||
gimp_image_exported (image, file);
|
||||
else
|
||||
gimp_image_saved (image, uri);
|
||||
gimp_image_saved (image, file);
|
||||
|
||||
documents = GIMP_DOCUMENT_LIST (image->gimp->documents);
|
||||
|
||||
|
@@ -214,15 +214,39 @@ file_utils_filename_from_uri (const gchar *uri)
|
||||
return filename;
|
||||
}
|
||||
|
||||
gchar *
|
||||
file_utils_uri_with_new_ext (const gchar *uri,
|
||||
const gchar *ext_uri)
|
||||
GFile *
|
||||
file_utils_file_with_new_ext (GFile *file,
|
||||
GFile *ext_file)
|
||||
{
|
||||
const gchar *uri_ext = file_utils_uri_get_ext (uri);
|
||||
const gchar *ext_uri_ext = ext_uri ? file_utils_uri_get_ext (ext_uri) : NULL;
|
||||
gchar *uri_without_ext = g_strndup (uri, uri_ext - uri);
|
||||
gchar *ret = g_strconcat (uri_without_ext, ext_uri_ext, NULL);
|
||||
gchar *uri;
|
||||
const gchar *uri_ext;
|
||||
gchar *ext_uri = NULL;
|
||||
const gchar *ext_uri_ext = NULL;
|
||||
gchar *uri_without_ext;
|
||||
gchar *new_uri;
|
||||
GFile *ret;
|
||||
|
||||
g_return_val_if_fail (G_IS_FILE (file), NULL);
|
||||
g_return_val_if_fail (ext_file == NULL || G_IS_FILE (ext_file), NULL);
|
||||
|
||||
uri = g_file_get_uri (file);
|
||||
uri_ext = file_utils_uri_get_ext (uri);
|
||||
|
||||
if (ext_uri)
|
||||
{
|
||||
ext_uri = g_file_get_uri (ext_file);
|
||||
ext_uri_ext = file_utils_uri_get_ext (ext_uri);
|
||||
}
|
||||
|
||||
uri_without_ext = g_strndup (uri, uri_ext - uri);
|
||||
|
||||
new_uri = g_strconcat (uri_without_ext, ext_uri_ext, NULL);
|
||||
|
||||
ret = g_file_new_for_uri (new_uri);
|
||||
|
||||
g_free (uri_without_ext);
|
||||
g_free (new_uri);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -428,36 +452,31 @@ gboolean
|
||||
file_utils_save_thumbnail (GimpImage *image,
|
||||
const gchar *filename)
|
||||
{
|
||||
const gchar *image_uri;
|
||||
gboolean success = FALSE;
|
||||
GFile *file;
|
||||
gboolean success = FALSE;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
|
||||
g_return_val_if_fail (filename != NULL, FALSE);
|
||||
|
||||
image_uri = gimp_image_get_uri (image);
|
||||
file = gimp_image_get_file (image);
|
||||
|
||||
if (image_uri)
|
||||
if (file)
|
||||
{
|
||||
gchar *uri = g_filename_to_uri (filename, NULL, NULL);
|
||||
gchar *image_uri = g_file_get_uri (file);
|
||||
gchar *uri = g_filename_to_uri (filename, NULL, NULL);
|
||||
|
||||
if (uri)
|
||||
if (uri && image_uri && ! strcmp (uri, image_uri))
|
||||
{
|
||||
if ( ! strcmp (uri, image_uri))
|
||||
{
|
||||
GimpImagefile *imagefile;
|
||||
GFile *file;
|
||||
GimpImagefile *imagefile;
|
||||
|
||||
file = g_file_new_for_uri (uri);
|
||||
imagefile = gimp_imagefile_new (image->gimp, file);
|
||||
g_object_unref (file);
|
||||
|
||||
success = gimp_imagefile_save_thumbnail (imagefile, NULL, image,
|
||||
NULL);
|
||||
g_object_unref (imagefile);
|
||||
}
|
||||
|
||||
g_free (uri);
|
||||
imagefile = gimp_imagefile_new (image->gimp, file);
|
||||
success = gimp_imagefile_save_thumbnail (imagefile, NULL, image,
|
||||
NULL);
|
||||
g_object_unref (imagefile);
|
||||
}
|
||||
|
||||
g_free (image_uri);
|
||||
g_free (uri);
|
||||
}
|
||||
|
||||
return success;
|
||||
|
@@ -28,8 +28,8 @@ gchar * file_utils_filename_to_uri (Gimp *gimp,
|
||||
GError **error);
|
||||
gchar * file_utils_filename_from_uri (const gchar *uri);
|
||||
gchar * file_utils_filename_from_file (GFile *file);
|
||||
gchar * file_utils_uri_with_new_ext (const gchar *uri,
|
||||
const gchar *uri_with_ext);
|
||||
GFile * file_utils_file_with_new_ext (GFile *file,
|
||||
GFile *ext_file);
|
||||
const gchar * file_utils_uri_get_ext (const gchar *uri);
|
||||
|
||||
gchar * file_utils_uri_to_utf8_filename (const gchar *uri);
|
||||
|
@@ -2250,9 +2250,9 @@ image_get_filename_invoker (GimpProcedure *procedure,
|
||||
|
||||
if (success)
|
||||
{
|
||||
const gchar *uri = gimp_image_get_any_uri (image);
|
||||
if (uri)
|
||||
filename = g_filename_from_uri (uri, NULL, NULL);
|
||||
GFile *file = gimp_image_get_any_file (image);
|
||||
if (file)
|
||||
filename = g_file_get_path (file);
|
||||
}
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||
@@ -2323,7 +2323,9 @@ image_get_uri_invoker (GimpProcedure *procedure,
|
||||
|
||||
if (success)
|
||||
{
|
||||
uri = g_strdup (gimp_image_get_any_uri (image));
|
||||
GFile *file = gimp_image_get_any_file (image);
|
||||
if (file)
|
||||
uri = g_file_get_uri (file);
|
||||
}
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||
@@ -2352,7 +2354,9 @@ image_get_xcf_uri_invoker (GimpProcedure *procedure,
|
||||
|
||||
if (success)
|
||||
{
|
||||
uri = g_strdup (gimp_image_get_uri (image));
|
||||
GFile *file = gimp_image_get_file (image);
|
||||
if (file)
|
||||
uri = g_file_get_uri (file);
|
||||
}
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||
@@ -2381,7 +2385,9 @@ image_get_imported_uri_invoker (GimpProcedure *procedure,
|
||||
|
||||
if (success)
|
||||
{
|
||||
uri = g_strdup (gimp_image_get_imported_uri (image));
|
||||
GFile *file = gimp_image_get_imported_file (image);
|
||||
if (file)
|
||||
uri = g_file_get_uri (file);
|
||||
}
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||
@@ -2410,7 +2416,9 @@ image_get_exported_uri_invoker (GimpProcedure *procedure,
|
||||
|
||||
if (success)
|
||||
{
|
||||
uri = g_strdup (gimp_image_get_exported_uri (image));
|
||||
GFile *file = gimp_image_get_exported_file (image);
|
||||
if (file)
|
||||
uri = g_file_get_uri (file);
|
||||
}
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||
|
@@ -123,9 +123,7 @@ static void gimp_file_dialog_help_clicked (GtkWidget *widge
|
||||
gpointer dialog);
|
||||
|
||||
static gchar * gimp_file_dialog_pattern_from_extension (const gchar *extension);
|
||||
static gchar * gimp_file_dialog_get_default_uri (Gimp *gimp);
|
||||
static gchar * gimp_file_dialog_get_dirname_from_uri (const gchar *uri);
|
||||
|
||||
static GFile * gimp_file_dialog_get_default_file (Gimp *gimp);
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GimpFileDialog, gimp_file_dialog,
|
||||
@@ -489,17 +487,17 @@ gimp_file_dialog_set_save_image (GimpFileDialog *dialog,
|
||||
gboolean close_after_saving,
|
||||
GimpObject *display)
|
||||
{
|
||||
const gchar *dir_uri = NULL;
|
||||
const gchar *name_uri = NULL;
|
||||
const gchar *ext_uri = NULL;
|
||||
gchar *default_uri = NULL;
|
||||
gchar *dirname = NULL;
|
||||
gchar *basename = NULL;
|
||||
GFile *dir_file = NULL;
|
||||
GFile *name_file = NULL;
|
||||
GFile *ext_file = NULL;
|
||||
GFile *default_file;
|
||||
GFile *parent_file;
|
||||
gchar *basename;
|
||||
|
||||
g_return_if_fail (GIMP_IS_FILE_DIALOG (dialog));
|
||||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
|
||||
default_uri = gimp_file_dialog_get_default_uri (gimp);
|
||||
default_file = gimp_file_dialog_get_default_file (gimp);
|
||||
|
||||
dialog->image = image;
|
||||
dialog->save_a_copy = save_a_copy;
|
||||
@@ -523,28 +521,24 @@ gimp_file_dialog_set_save_image (GimpFileDialog *dialog,
|
||||
*/
|
||||
|
||||
if (save_a_copy)
|
||||
dir_uri = gimp_image_get_save_a_copy_uri (image);
|
||||
dir_file = gimp_image_get_save_a_copy_file (image);
|
||||
|
||||
if (! dir_uri)
|
||||
dir_uri = gimp_image_get_uri (image);
|
||||
if (! dir_file)
|
||||
dir_file = gimp_image_get_file (image);
|
||||
|
||||
if (! dir_uri)
|
||||
dir_uri = g_object_get_data (G_OBJECT (image),
|
||||
"gimp-image-source-uri");
|
||||
if (! dir_file)
|
||||
dir_file = g_object_get_data (G_OBJECT (image),
|
||||
"gimp-image-source-file");
|
||||
|
||||
if (! dir_uri)
|
||||
dir_uri = gimp_image_get_imported_uri (image);
|
||||
if (! dir_file)
|
||||
dir_file = gimp_image_get_imported_file (image);
|
||||
|
||||
if (! dir_uri)
|
||||
{
|
||||
GFile *file = g_object_get_data (G_OBJECT (gimp),
|
||||
GIMP_FILE_SAVE_LAST_FILE_KEY);
|
||||
if (file)
|
||||
dir_uri = g_file_get_uri (file); /* FIXME leak */
|
||||
}
|
||||
if (! dir_file)
|
||||
dir_file = g_object_get_data (G_OBJECT (gimp),
|
||||
GIMP_FILE_SAVE_LAST_FILE_KEY);
|
||||
|
||||
if (! dir_uri)
|
||||
dir_uri = default_uri;
|
||||
if (! dir_file)
|
||||
dir_file = default_file;
|
||||
|
||||
|
||||
/* Priority of default basenames for Save:
|
||||
@@ -557,19 +551,20 @@ gimp_file_dialog_set_save_image (GimpFileDialog *dialog,
|
||||
*/
|
||||
|
||||
if (save_a_copy)
|
||||
name_uri = gimp_image_get_save_a_copy_uri (image);
|
||||
name_file = gimp_image_get_save_a_copy_file (image);
|
||||
|
||||
if (! name_uri)
|
||||
name_uri = gimp_image_get_uri (image);
|
||||
if (! name_file)
|
||||
name_file = gimp_image_get_file (image);
|
||||
|
||||
if (! name_uri)
|
||||
name_uri = gimp_image_get_exported_uri (image);
|
||||
if (! name_file)
|
||||
name_file = gimp_image_get_exported_file (image);
|
||||
|
||||
if (! name_uri)
|
||||
name_uri = gimp_image_get_imported_uri (image);
|
||||
if (! name_file)
|
||||
name_file = gimp_image_get_imported_file (image);
|
||||
|
||||
if (! name_uri)
|
||||
name_uri = gimp_image_get_string_untitled ();
|
||||
if (! name_file)
|
||||
/* XXX leak */
|
||||
name_file = g_file_new_for_uri (gimp_image_get_string_untitled ());
|
||||
|
||||
|
||||
/* Priority of default type/extension for Save:
|
||||
@@ -577,10 +572,10 @@ gimp_file_dialog_set_save_image (GimpFileDialog *dialog,
|
||||
* 1. Type of last Save
|
||||
* 2. .xcf (which we don't explicitly append)
|
||||
*/
|
||||
ext_uri = gimp_image_get_uri (image);
|
||||
ext_file = gimp_image_get_file (image);
|
||||
|
||||
if (! ext_uri)
|
||||
ext_uri = "file:///we/only/care/about/extension.xcf";
|
||||
if (! ext_file)
|
||||
ext_file = g_file_new_for_uri ("file:///we/only/care/about/extension.xcf");
|
||||
}
|
||||
else /* if (export) */
|
||||
{
|
||||
@@ -595,36 +590,28 @@ gimp_file_dialog_set_save_image (GimpFileDialog *dialog,
|
||||
* 6. The default path (usually the OS 'Documents' path)
|
||||
*/
|
||||
|
||||
dir_uri = gimp_image_get_exported_uri (image);
|
||||
dir_file = gimp_image_get_exported_file (image);
|
||||
|
||||
if (! dir_uri)
|
||||
dir_uri = g_object_get_data (G_OBJECT (image),
|
||||
"gimp-image-source-uri");
|
||||
if (! dir_file)
|
||||
dir_file = g_object_get_data (G_OBJECT (image),
|
||||
"gimp-image-source-file");
|
||||
|
||||
if (! dir_uri)
|
||||
dir_uri = gimp_image_get_imported_uri (image);
|
||||
if (! dir_file)
|
||||
dir_file = gimp_image_get_imported_file (image);
|
||||
|
||||
if (! dir_uri)
|
||||
dir_uri = gimp_image_get_uri (image);
|
||||
if (! dir_file)
|
||||
dir_file = gimp_image_get_file (image);
|
||||
|
||||
if (! dir_uri)
|
||||
{
|
||||
GFile *file = g_object_get_data (G_OBJECT (gimp),
|
||||
GIMP_FILE_SAVE_LAST_FILE_KEY);
|
||||
if (file)
|
||||
dir_uri = g_file_get_uri (file); /* XXX fixme leak */
|
||||
}
|
||||
if (! dir_file)
|
||||
dir_file = g_object_get_data (G_OBJECT (gimp),
|
||||
GIMP_FILE_SAVE_LAST_FILE_KEY);
|
||||
|
||||
if (! dir_uri)
|
||||
{
|
||||
GFile *file = g_object_get_data (G_OBJECT (gimp),
|
||||
GIMP_FILE_EXPORT_LAST_FILE_KEY);
|
||||
if (file)
|
||||
dir_uri = g_file_get_uri (file); /* XXX fixme leak */
|
||||
}
|
||||
if (! dir_file)
|
||||
dir_file = g_object_get_data (G_OBJECT (gimp),
|
||||
GIMP_FILE_EXPORT_LAST_FILE_KEY);
|
||||
|
||||
if (! dir_uri)
|
||||
dir_uri = default_uri;
|
||||
if (! dir_file)
|
||||
dir_file = default_file;
|
||||
|
||||
|
||||
/* Priority of default basenames for Export:
|
||||
@@ -635,16 +622,17 @@ gimp_file_dialog_set_save_image (GimpFileDialog *dialog,
|
||||
* 3. 'Untitled'
|
||||
*/
|
||||
|
||||
name_uri = gimp_image_get_exported_uri (image);
|
||||
name_file = gimp_image_get_exported_file (image);
|
||||
|
||||
if (! name_uri)
|
||||
name_uri = gimp_image_get_uri (image);
|
||||
if (! name_file)
|
||||
name_file = gimp_image_get_file (image);
|
||||
|
||||
if (! name_uri)
|
||||
name_uri = gimp_image_get_imported_uri (image);
|
||||
if (! name_file)
|
||||
name_file = gimp_image_get_imported_file (image);
|
||||
|
||||
if (! name_uri)
|
||||
name_uri = gimp_image_get_string_untitled ();
|
||||
if (! name_file)
|
||||
/* XXX leak */
|
||||
name_file = g_file_new_for_uri (gimp_image_get_string_untitled ());
|
||||
|
||||
|
||||
/* Priority of default type/extension for Export:
|
||||
@@ -654,43 +642,36 @@ gimp_file_dialog_set_save_image (GimpFileDialog *dialog,
|
||||
* 3. Type of latest Export of any document
|
||||
* 4. .png
|
||||
*/
|
||||
ext_uri = gimp_image_get_exported_uri (image);
|
||||
ext_file = gimp_image_get_exported_file (image);
|
||||
|
||||
if (! ext_uri)
|
||||
ext_uri = gimp_image_get_imported_uri (image);
|
||||
if (! ext_file)
|
||||
ext_file = gimp_image_get_imported_file (image);
|
||||
|
||||
if (! ext_uri)
|
||||
{
|
||||
GFile *file = g_object_get_data (G_OBJECT (gimp),
|
||||
GIMP_FILE_EXPORT_LAST_FILE_KEY);
|
||||
if (file)
|
||||
ext_uri = g_file_get_uri (file); /* XXX fixme leak */
|
||||
}
|
||||
if (! ext_file)
|
||||
ext_file = g_object_get_data (G_OBJECT (gimp),
|
||||
GIMP_FILE_EXPORT_LAST_FILE_KEY);
|
||||
|
||||
if (! ext_uri)
|
||||
ext_uri = "file:///we/only/care/about/extension.png";
|
||||
if (! ext_file)
|
||||
ext_file = g_file_new_for_uri ("file:///we/only/care/about/extension.png");
|
||||
}
|
||||
|
||||
dirname = gimp_file_dialog_get_dirname_from_uri (dir_uri);
|
||||
|
||||
if (ext_uri)
|
||||
if (ext_file)
|
||||
{
|
||||
gchar *uri_new_ext = file_utils_uri_with_new_ext (name_uri,
|
||||
ext_uri);
|
||||
basename = file_utils_uri_display_basename (uri_new_ext);
|
||||
g_free (uri_new_ext);
|
||||
GFile *tmp_file = file_utils_file_with_new_ext (name_file, ext_file);
|
||||
basename = g_path_get_basename (gimp_file_get_utf8_name (tmp_file));
|
||||
g_object_unref (tmp_file);
|
||||
}
|
||||
else
|
||||
{
|
||||
basename = file_utils_uri_display_basename (name_uri);
|
||||
basename = g_path_get_basename (gimp_file_get_utf8_name (name_file));
|
||||
}
|
||||
|
||||
gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dialog), dirname);
|
||||
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), basename);
|
||||
parent_file = g_file_get_parent (dir_file);
|
||||
gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (dialog),
|
||||
parent_file, NULL);
|
||||
g_object_unref (parent_file);
|
||||
|
||||
g_free (default_uri);
|
||||
g_free (basename);
|
||||
g_free (dirname);
|
||||
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), basename);
|
||||
}
|
||||
|
||||
GimpFileDialogState *
|
||||
@@ -1158,91 +1139,34 @@ gimp_file_dialog_pattern_from_extension (const gchar *extension)
|
||||
return pattern;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
gimp_file_dialog_get_default_uri (Gimp *gimp)
|
||||
static GFile *
|
||||
gimp_file_dialog_get_default_file (Gimp *gimp)
|
||||
{
|
||||
if (gimp->default_folder)
|
||||
{
|
||||
return g_strdup (gimp->default_folder);
|
||||
return g_file_new_for_path (gimp->default_folder);
|
||||
}
|
||||
else
|
||||
{
|
||||
GFile *file;
|
||||
gchar *path;
|
||||
gchar *uri;
|
||||
|
||||
/* Make sure it ends in '/' */
|
||||
path = g_build_path (G_DIR_SEPARATOR_S,
|
||||
g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS),
|
||||
G_DIR_SEPARATOR_S,
|
||||
NULL);
|
||||
uri = g_filename_to_uri (path, NULL, NULL);
|
||||
g_free (path);
|
||||
|
||||
/* Paranoia fallback, see bug #722400 */
|
||||
if (! uri)
|
||||
{
|
||||
path = g_build_path (G_DIR_SEPARATOR_S,
|
||||
g_get_home_dir (),
|
||||
G_DIR_SEPARATOR_S,
|
||||
NULL);
|
||||
uri = g_filename_to_uri (path, NULL, NULL);
|
||||
g_free (path);
|
||||
}
|
||||
if (! path)
|
||||
path = g_build_path (G_DIR_SEPARATOR_S,
|
||||
g_get_home_dir (),
|
||||
G_DIR_SEPARATOR_S,
|
||||
NULL);
|
||||
|
||||
return uri;
|
||||
file = g_file_new_for_path (path);
|
||||
g_free (path);
|
||||
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
||||
static gchar *
|
||||
gimp_file_dialog_get_dirname_from_uri (const gchar *uri)
|
||||
{
|
||||
gchar *dirname = NULL;
|
||||
|
||||
#ifndef G_OS_WIN32
|
||||
dirname = g_path_get_dirname (uri);
|
||||
#else
|
||||
/* g_path_get_dirname() is supposed to work on pathnames, not URIs.
|
||||
*
|
||||
* If uri points to a file on the root of a drive
|
||||
* "file:///d:/foo.png", g_path_get_dirname() would return
|
||||
* "file:///d:". (What we really would want is "file:///d:/".) When
|
||||
* this then is passed inside gtk+ to g_filename_from_uri() we get
|
||||
* "d:" which is not an absolute pathname. This currently causes an
|
||||
* assertion failure in gtk+. This scenario occurs if we have opened
|
||||
* an image from the root of a drive and then do Save As.
|
||||
*
|
||||
* Of course, gtk+ shouldn't assert even if we feed it slightly bogus
|
||||
* data, and that problem should be fixed, too. But to get the
|
||||
* correct default current folder in the filechooser combo box, we
|
||||
* need to pass it the proper URI for an absolute path anyway. So
|
||||
* don't use g_path_get_dirname() on file: URIs.
|
||||
*/
|
||||
if (g_str_has_prefix (uri, "file:///"))
|
||||
{
|
||||
gchar *filepath = g_filename_from_uri (uri, NULL, NULL);
|
||||
gchar *dirpath = NULL;
|
||||
|
||||
if (filepath != NULL)
|
||||
{
|
||||
dirpath = g_path_get_dirname (filepath);
|
||||
g_free (filepath);
|
||||
}
|
||||
|
||||
if (dirpath != NULL)
|
||||
{
|
||||
dirname = g_filename_to_uri (dirpath, NULL, NULL);
|
||||
g_free (dirpath);
|
||||
}
|
||||
else
|
||||
{
|
||||
dirname = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dirname = g_path_get_dirname (uri);
|
||||
}
|
||||
#endif
|
||||
|
||||
return dirname;
|
||||
}
|
||||
|
@@ -305,14 +305,12 @@ static void
|
||||
gimp_image_prop_view_label_set_filename (GtkWidget *label,
|
||||
GimpImage *image)
|
||||
{
|
||||
const gchar *uri = gimp_image_get_any_uri (image);
|
||||
GFile *file = gimp_image_get_any_file (image);
|
||||
|
||||
if (uri)
|
||||
if (file)
|
||||
{
|
||||
gchar *name = file_utils_uri_display_name (uri);
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (label), name);
|
||||
g_free (name);
|
||||
gtk_label_set_text (GTK_LABEL (label),
|
||||
gimp_file_get_utf8_name (file));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -325,11 +323,7 @@ static void
|
||||
gimp_image_prop_view_label_set_filesize (GtkWidget *label,
|
||||
GimpImage *image)
|
||||
{
|
||||
const gchar *uri = gimp_image_get_any_uri (image);
|
||||
GFile *file = NULL;
|
||||
|
||||
if (uri)
|
||||
file = g_file_new_for_uri (uri);
|
||||
GFile *file = gimp_image_get_any_file (image);
|
||||
|
||||
if (file)
|
||||
{
|
||||
@@ -352,8 +346,6 @@ gimp_image_prop_view_label_set_filesize (GtkWidget *label,
|
||||
{
|
||||
gtk_label_set_text (GTK_LABEL (label), NULL);
|
||||
}
|
||||
|
||||
g_object_unref (file);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -375,16 +367,10 @@ gimp_image_prop_view_label_set_filetype (GtkWidget *label,
|
||||
|
||||
if (! proc)
|
||||
{
|
||||
const gchar *uri = gimp_image_get_uri (image);
|
||||
GFile *file = gimp_image_get_file (image);
|
||||
|
||||
if (uri)
|
||||
{
|
||||
GFile *file;
|
||||
|
||||
file = g_file_new_for_uri (uri);
|
||||
proc = file_procedure_find (manager->load_procs, file, NULL);
|
||||
g_object_unref (file);
|
||||
}
|
||||
if (file)
|
||||
proc = file_procedure_find (manager->load_procs, file, NULL);
|
||||
}
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (label),
|
||||
|
@@ -2245,9 +2245,9 @@ HELP
|
||||
%invoke = (
|
||||
code => <<'CODE'
|
||||
{
|
||||
const gchar *uri = gimp_image_get_any_uri (image);
|
||||
if (uri)
|
||||
filename = g_filename_from_uri (uri, NULL, NULL);
|
||||
GFile *file = gimp_image_get_any_file (image);
|
||||
if (file)
|
||||
filename = g_file_get_path (file);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
@@ -2325,7 +2325,9 @@ HELP
|
||||
%invoke = (
|
||||
code => <<'CODE'
|
||||
{
|
||||
uri = g_strdup (gimp_image_get_any_uri (image));
|
||||
GFile *file = gimp_image_get_any_file (image);
|
||||
if (file)
|
||||
uri = g_file_get_uri (file);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
@@ -2357,7 +2359,9 @@ HELP
|
||||
%invoke = (
|
||||
code => <<'CODE'
|
||||
{
|
||||
uri = g_strdup (gimp_image_get_uri (image));
|
||||
GFile *file = gimp_image_get_file (image);
|
||||
if (file)
|
||||
uri = g_file_get_uri (file);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
@@ -2391,7 +2395,9 @@ HELP
|
||||
%invoke = (
|
||||
code => <<'CODE'
|
||||
{
|
||||
uri = g_strdup (gimp_image_get_imported_uri (image));
|
||||
GFile *file = gimp_image_get_imported_file (image);
|
||||
if (file)
|
||||
uri = g_file_get_uri (file);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
@@ -2424,7 +2430,9 @@ HELP
|
||||
%invoke = (
|
||||
code => <<'CODE'
|
||||
{
|
||||
uri = g_strdup (gimp_image_get_exported_uri (image));
|
||||
GFile *file = gimp_image_get_exported_file (image);
|
||||
if (file)
|
||||
uri = g_file_get_uri (file);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
|
Reference in New Issue
Block a user