mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-05 02:09:37 +00:00
app: keep the image's "Untitled" string around as GFile too
This commit is contained in:
parent
f5afc78532
commit
7f966cad39
4 changed files with 47 additions and 34 deletions
|
@ -62,6 +62,7 @@ struct _GimpImagePrivate
|
||||||
GFile *imported_file; /* the image's source file */
|
GFile *imported_file; /* the image's source file */
|
||||||
GFile *exported_file; /* the image's export file */
|
GFile *exported_file; /* the image's export file */
|
||||||
GFile *save_a_copy_file; /* the image's save-a-copy file */
|
GFile *save_a_copy_file; /* the image's save-a-copy file */
|
||||||
|
GFile *untitled_file; /* a file saying "Untitled" */
|
||||||
|
|
||||||
gint dirty; /* dirty flag -- # of ops */
|
gint dirty; /* dirty flag -- # of ops */
|
||||||
guint dirty_time; /* time when image became dirty */
|
guint dirty_time; /* time when image became dirty */
|
||||||
|
|
|
@ -993,6 +993,12 @@ gimp_image_finalize (GObject *object)
|
||||||
private->save_a_copy_file = NULL;
|
private->save_a_copy_file = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (private->untitled_file)
|
||||||
|
{
|
||||||
|
g_object_unref (private->untitled_file);
|
||||||
|
private->untitled_file = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (private->layers)
|
if (private->layers)
|
||||||
{
|
{
|
||||||
g_object_unref (private->layers);
|
g_object_unref (private->layers);
|
||||||
|
@ -1866,35 +1872,46 @@ gimp_image_take_uri (GimpImage *image,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gimp_image_get_untitled_string:
|
* gimp_image_get_untitled_file:
|
||||||
*
|
*
|
||||||
* Returns: The (translated) "Untitled" string for newly created
|
* Returns: A #GFile saying "Untitled" for newly created images.
|
||||||
* images.
|
|
||||||
**/
|
**/
|
||||||
const gchar *
|
GFile *
|
||||||
gimp_image_get_string_untitled (void)
|
gimp_image_get_untitled_file (const GimpImage *image)
|
||||||
{
|
{
|
||||||
return _("Untitled");
|
GimpImagePrivate *private;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gimp_image_get_uri_or_untitled:
|
|
||||||
* @image: A #GimpImage.
|
|
||||||
*
|
|
||||||
* Get the URI of the XCF image, or "Untitled" if there is no URI.
|
|
||||||
*
|
|
||||||
* Returns: The URI, or "Untitled".
|
|
||||||
**/
|
|
||||||
const gchar *
|
|
||||||
gimp_image_get_uri_or_untitled (const GimpImage *image)
|
|
||||||
{
|
|
||||||
const gchar *uri;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||||
|
|
||||||
uri = gimp_object_get_name (image);
|
private = GIMP_IMAGE_GET_PRIVATE (image);
|
||||||
|
|
||||||
return uri ? uri : gimp_image_get_string_untitled ();
|
if (! private->untitled_file)
|
||||||
|
private->untitled_file = g_file_new_for_uri (_("Untitled"));
|
||||||
|
|
||||||
|
return private->untitled_file;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gimp_image_get_file_or_untitled:
|
||||||
|
* @image: A #GimpImage.
|
||||||
|
*
|
||||||
|
* Get the file of the XCF image, or the "Untitled" file if there is no file.
|
||||||
|
*
|
||||||
|
* Returns: A #GFile.
|
||||||
|
**/
|
||||||
|
GFile *
|
||||||
|
gimp_image_get_file_or_untitled (const GimpImage *image)
|
||||||
|
{
|
||||||
|
GFile *file;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||||
|
|
||||||
|
file = gimp_image_get_file (image);
|
||||||
|
|
||||||
|
if (! file)
|
||||||
|
file = gimp_image_get_untitled_file (image);
|
||||||
|
|
||||||
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2141,7 +2158,7 @@ gimp_image_format_display_uri (GimpImage *image,
|
||||||
|
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
display_file = g_object_ref (file);
|
display_file = file;
|
||||||
uri_format = "%s";
|
uri_format = "%s";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2178,15 +2195,13 @@ gimp_image_format_display_uri (GimpImage *image,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! display_file)
|
if (! display_file)
|
||||||
display_file = g_file_new_for_uri (gimp_image_get_string_untitled ());
|
display_file = gimp_image_get_untitled_file (image);
|
||||||
|
|
||||||
if (basename)
|
if (basename)
|
||||||
display_uri = g_path_get_basename (gimp_file_get_utf8_name (display_file));
|
display_uri = g_path_get_basename (gimp_file_get_utf8_name (display_file));
|
||||||
else
|
else
|
||||||
display_uri = g_strdup (gimp_file_get_utf8_name (display_file));
|
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);
|
format_string = g_strconcat (uri_format, export_status, NULL);
|
||||||
|
|
||||||
tmp = g_strdup_printf (format_string, display_uri);
|
tmp = g_strdup_printf (format_string, display_uri);
|
||||||
|
|
|
@ -133,7 +133,8 @@ GimpImage * gimp_image_get_by_ID (Gimp *gimp,
|
||||||
gint id);
|
gint id);
|
||||||
|
|
||||||
GFile * gimp_image_get_file (const GimpImage *image);
|
GFile * gimp_image_get_file (const GimpImage *image);
|
||||||
const gchar * gimp_image_get_uri_or_untitled (const GimpImage *image);
|
GFile * gimp_image_get_untitled_file (const GimpImage *image);
|
||||||
|
GFile * gimp_image_get_file_or_untitled (const GimpImage *image);
|
||||||
GFile * gimp_image_get_imported_file (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_exported_file (const GimpImage *image);
|
||||||
GFile * gimp_image_get_save_a_copy_file (const GimpImage *image);
|
GFile * gimp_image_get_save_a_copy_file (const GimpImage *image);
|
||||||
|
@ -429,7 +430,5 @@ gboolean gimp_image_coords_in_active_pickable (GimpImage *image,
|
||||||
|
|
||||||
void gimp_image_invalidate_previews (GimpImage *image);
|
void gimp_image_invalidate_previews (GimpImage *image);
|
||||||
|
|
||||||
const gchar * gimp_image_get_string_untitled (void);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_IMAGE_H__ */
|
#endif /* __GIMP_IMAGE_H__ */
|
||||||
|
|
|
@ -563,8 +563,7 @@ gimp_file_dialog_set_save_image (GimpFileDialog *dialog,
|
||||||
name_file = gimp_image_get_imported_file (image);
|
name_file = gimp_image_get_imported_file (image);
|
||||||
|
|
||||||
if (! name_file)
|
if (! name_file)
|
||||||
/* XXX leak */
|
name_file = gimp_image_get_untitled_file (image);
|
||||||
name_file = g_file_new_for_uri (gimp_image_get_string_untitled ());
|
|
||||||
|
|
||||||
|
|
||||||
/* Priority of default type/extension for Save:
|
/* Priority of default type/extension for Save:
|
||||||
|
@ -631,8 +630,7 @@ gimp_file_dialog_set_save_image (GimpFileDialog *dialog,
|
||||||
name_file = gimp_image_get_imported_file (image);
|
name_file = gimp_image_get_imported_file (image);
|
||||||
|
|
||||||
if (! name_file)
|
if (! name_file)
|
||||||
/* XXX leak */
|
name_file = gimp_image_get_untitled_file (image);
|
||||||
name_file = g_file_new_for_uri (gimp_image_get_string_untitled ());
|
|
||||||
|
|
||||||
|
|
||||||
/* Priority of default type/extension for Export:
|
/* Priority of default type/extension for Export:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue