Commit ada83368 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

added gimp_image_get_display_name().

2008-11-13  Sven Neumann  <sven@gimp.org>

	* app/core/gimpimage.[ch]: added gimp_image_get_display_name().

	* app/dialogs/palette-import-dialog.c
	* app/display/gimpdisplayshell-close.c
	* app/display/gimpdisplayshell-title.c
	* app/pdb/gimppdb-utils.c

	* app/widgets/gimpviewabledialog.c: use the new method instead 
of
	getting the image URI and mangling it with
	file_utils_uri_display_basename().


svn path=/trunk/; revision=27637
parent f26fb06d
2008-11-13 Sven Neumann <sven@gimp.org>
* app/core/gimpimage.[ch]: added gimp_image_get_display_name().
* app/dialogs/palette-import-dialog.c
* app/display/gimpdisplayshell-close.c
* app/display/gimpdisplayshell-title.c
* app/pdb/gimppdb-utils.c
* app/widgets/gimpviewabledialog.c: use the new method instead of
getting the image URI and mangling it with
file_utils_uri_display_basename().
2008-11-13 Sven Neumann <sven@gimp.org>
Bug 559292 – SOTA Chrome cannot accept different textures
......
......@@ -948,17 +948,30 @@ gimp_image_finalize (GObject *object)
image->gimp = NULL;
}
if (image->display_name)
{
g_free (image->display_name);
image->display_name = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_image_name_changed (GimpObject *object)
{
GimpImage *image = GIMP_IMAGE (object);
const gchar *name;
if (GIMP_OBJECT_CLASS (parent_class)->name_changed)
GIMP_OBJECT_CLASS (parent_class)->name_changed (object);
if (image->display_name)
{
g_free (image->display_name);
image->display_name = NULL;
}
name = gimp_object_get_name (object);
if (! (name && strlen (name)))
......@@ -1081,23 +1094,16 @@ static gchar *
gimp_image_get_description (GimpViewable *viewable,
gchar **tooltip)
{
GimpImage *image = GIMP_IMAGE (viewable);
const gchar *uri;
gchar *basename;
gchar *retval;
uri = gimp_image_get_uri (GIMP_IMAGE (image));
basename = file_utils_uri_display_basename (uri);
GimpImage *image = GIMP_IMAGE (viewable);
if (tooltip)
*tooltip = file_utils_uri_display_name (uri);
retval = g_strdup_printf ("%s-%d", basename, gimp_image_get_ID (image));
g_free (basename);
{
*tooltip = file_utils_uri_display_name (gimp_image_get_uri (image));
}
return retval;
return g_strdup_printf ("%s-%d",
gimp_image_get_display_name (image),
gimp_image_get_ID (image));
}
static void
......@@ -1440,6 +1446,21 @@ gimp_image_get_filename (const GimpImage *image)
return g_filename_from_uri (uri, NULL, NULL);
}
const gchar *
gimp_image_get_display_name (GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
if (! image->display_name)
{
const gchar *uri = gimp_image_get_uri (image);
image->display_name = file_utils_uri_display_basename (uri);
}
return image->display_name;
}
void
gimp_image_set_load_proc (GimpImage *image,
GimpPlugInProcedure *proc)
......
......@@ -107,6 +107,7 @@ struct _GimpImage
GimpPlugInProcedure *load_proc; /* procedure used for loading */
GimpPlugInProcedure *save_proc; /* last save procedure used */
gchar *display_name; /* display basename */
gint width, height; /* width and height attributes */
gdouble xresolution; /* image x-res, in dpi */
gdouble yresolution; /* image y-res, in dpi */
......@@ -249,6 +250,8 @@ void gimp_image_set_filename (GimpImage *image,
const gchar *filename);
gchar * gimp_image_get_filename (const GimpImage *image);
const gchar * gimp_image_get_display_name (GimpImage *image);
void gimp_image_set_load_proc (GimpImage *image,
GimpPlugInProcedure *proc);
GimpPlugInProcedure * gimp_image_get_load_proc (const GimpImage *image);
......
......@@ -38,8 +38,6 @@
#include "core/gimppalette.h"
#include "core/gimppalette-import.h"
#include "file/file-utils.h"
#include "widgets/gimpcontainercombobox.h"
#include "widgets/gimpdnd.h"
#include "widgets/gimphelp-ids.h"
......@@ -508,12 +506,11 @@ palette_import_image_changed (GimpContext *context,
if (image)
{
gchar *name;
gchar *label;
name = file_utils_uri_display_basename (gimp_image_get_uri (image));
label = g_strdup_printf ("%s-%d", name, gimp_image_get_ID (image));
g_free (name);
label = g_strdup_printf ("%s-%d",
gimp_image_get_display_name (image),
gimp_image_get_ID (image));
gtk_entry_set_text (GTK_ENTRY (dialog->entry), label);
g_free (label);
......
......@@ -134,7 +134,6 @@ gimp_display_shell_close_dialog (GimpDisplayShell *shell,
GimpMessageBox *box;
GClosure *closure;
GSource *source;
gchar *name;
gchar *title;
if (shell->close_dialog)
......@@ -143,10 +142,7 @@ gimp_display_shell_close_dialog (GimpDisplayShell *shell,
return;
}
name = file_utils_uri_display_basename (gimp_image_get_uri (image));
title = g_strdup_printf (_("Close %s"), name);
g_free (name);
title = g_strdup_printf (_("Close %s"), gimp_image_get_display_name (image));
shell->close_dialog =
dialog = gimp_message_dialog_new (title, GTK_STOCK_SAVE,
......@@ -216,13 +212,11 @@ gimp_display_shell_close_name_changed (GimpImage *image,
GimpMessageBox *box)
{
GtkWidget *window = gtk_widget_get_toplevel (GTK_WIDGET (box));
gchar *name;
name = file_utils_uri_display_basename (gimp_image_get_uri (image));
if (window)
{
gchar *title = g_strdup_printf (_("Close %s"), name);
gchar *title = g_strdup_printf (_("Close %s"),
gimp_image_get_display_name (image));
gtk_window_set_title (GTK_WINDOW (window), title);
g_free (title);
......@@ -231,8 +225,7 @@ gimp_display_shell_close_name_changed (GimpImage *image,
gimp_message_box_set_primary_text (box,
_("Save the changes to image '%s' "
"before closing?"),
name);
g_free (name);
gimp_image_get_display_name (image));
}
......
......@@ -189,22 +189,17 @@ gimp_display_shell_format_title (GimpDisplayShell *shell,
title[i++] = '%';
break;
case 'f': /* pruned filename */
case 'f': /* base filename */
{
const gchar *uri = gimp_image_get_uri (image);
gchar *basename;
basename = file_utils_uri_display_basename (uri);
i += print (title, title_len, i, "%s", basename);
const gchar *name = gimp_image_get_display_name (image);
g_free (basename);
i += print (title, title_len, i, "%s", name);
}
break;
case 'F': /* full filename */
{
gchar *filename;
gchar *filename;
const gchar *uri = gimp_image_get_uri (image);
filename = file_utils_uri_display_name (uri);
......
......@@ -32,8 +32,6 @@
#include "core/gimpimage.h"
#include "core/gimpitem.h"
#include "file/file-utils.h"
#include "text/gimptextlayer.h"
#include "vectors/gimpvectors.h"
......@@ -387,27 +385,21 @@ gimp_pdb_image_is_base_type (GimpImage *image,
GimpImageBaseType type,
GError **error)
{
gchar *name;
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (gimp_image_base_type (image) == type)
return TRUE;
name = file_utils_uri_display_basename (gimp_image_get_uri (image));
g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_INVALID_ARGUMENT,
_("Image '%s' (%d) is of type '%s', "
"but an image of type '%s' is expected"),
name,
gimp_image_get_display_name (image),
gimp_image_get_ID (image),
gimp_pdb_enum_value_get_nick (GIMP_TYPE_IMAGE_BASE_TYPE,
gimp_image_base_type (image)),
gimp_pdb_enum_value_get_nick (GIMP_TYPE_IMAGE_BASE_TYPE, type));
g_free (name);
return FALSE;
}
......@@ -416,24 +408,18 @@ gimp_pdb_image_is_not_base_type (GimpImage *image,
GimpImageBaseType type,
GError **error)
{
gchar *name;
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (gimp_image_base_type (image) != type)
return TRUE;
name = file_utils_uri_display_basename (gimp_image_get_uri (image));
g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_INVALID_ARGUMENT,
_("Image '%s' (%d) is already of type '%s'"),
name,
gimp_image_get_display_name (image),
gimp_image_get_ID (image),
gimp_pdb_enum_value_get_nick (GIMP_TYPE_IMAGE_BASE_TYPE, type));
g_free (name);
return FALSE;
}
......
......@@ -372,20 +372,14 @@ gimp_viewable_dialog_name_changed (GimpObject *object,
if (GIMP_IS_ITEM (object))
{
const gchar *uri;
gchar *basename;
gchar *tmp;
GimpImage *image = gimp_item_get_image (GIMP_ITEM (object));
gchar *tmp;
uri = gimp_image_get_uri (gimp_item_get_image (GIMP_ITEM (object)));
tmp = name;
basename = file_utils_uri_display_basename (uri);
name = g_strdup_printf ("%s-%d (%s)",
tmp,
gimp_item_get_ID (GIMP_ITEM (object)),
basename);
g_free (basename);
gimp_image_get_display_name (image));
g_free (tmp);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment