gimp r27637 - in trunk: . app/core app/dialogs app/display app/pdb app/widgets
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r27637 - in trunk: . app/core app/dialogs app/display app/pdb app/widgets
- Date: Thu, 13 Nov 2008 12:09:05 +0000 (UTC)
Author: neo
Date: Thu Nov 13 12:09:05 2008
New Revision: 27637
URL: http://svn.gnome.org/viewvc/gimp?rev=27637&view=rev
Log:
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().
Modified:
trunk/ChangeLog
trunk/app/core/gimpimage.c
trunk/app/core/gimpimage.h
trunk/app/dialogs/palette-import-dialog.c
trunk/app/display/gimpdisplayshell-close.c
trunk/app/display/gimpdisplayshell-title.c
trunk/app/pdb/gimppdb-utils.c
trunk/app/widgets/gimpviewabledialog.c
Modified: trunk/app/core/gimpimage.c
==============================================================================
--- trunk/app/core/gimpimage.c (original)
+++ trunk/app/core/gimpimage.c Thu Nov 13 12:09:05 2008
@@ -948,17 +948,30 @@
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 @@
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 @@
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)
Modified: trunk/app/core/gimpimage.h
==============================================================================
--- trunk/app/core/gimpimage.h (original)
+++ trunk/app/core/gimpimage.h Thu Nov 13 12:09:05 2008
@@ -107,6 +107,7 @@
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 @@
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);
Modified: trunk/app/dialogs/palette-import-dialog.c
==============================================================================
--- trunk/app/dialogs/palette-import-dialog.c (original)
+++ trunk/app/dialogs/palette-import-dialog.c Thu Nov 13 12:09:05 2008
@@ -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 @@
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);
Modified: trunk/app/display/gimpdisplayshell-close.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-close.c (original)
+++ trunk/app/display/gimpdisplayshell-close.c Thu Nov 13 12:09:05 2008
@@ -134,7 +134,6 @@
GimpMessageBox *box;
GClosure *closure;
GSource *source;
- gchar *name;
gchar *title;
if (shell->close_dialog)
@@ -143,10 +142,7 @@
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 @@
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_message_box_set_primary_text (box,
_("Save the changes to image '%s' "
"before closing?"),
- name);
- g_free (name);
+ gimp_image_get_display_name (image));
}
Modified: trunk/app/display/gimpdisplayshell-title.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-title.c (original)
+++ trunk/app/display/gimpdisplayshell-title.c Thu Nov 13 12:09:05 2008
@@ -189,22 +189,17 @@
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);
Modified: trunk/app/pdb/gimppdb-utils.c
==============================================================================
--- trunk/app/pdb/gimppdb-utils.c (original)
+++ trunk/app/pdb/gimppdb-utils.c Thu Nov 13 12:09:05 2008
@@ -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 @@
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 @@
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;
}
Modified: trunk/app/widgets/gimpviewabledialog.c
==============================================================================
--- trunk/app/widgets/gimpviewabledialog.c (original)
+++ trunk/app/widgets/gimpviewabledialog.c Thu Nov 13 12:09:05 2008
@@ -372,20 +372,14 @@
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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]