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

introduced variants of file_utils_uri_to_utf8_filename() and

2005-10-02  Sven Neumann  <sven@gimp.org>

	* app/file/file-utils.[ch]: introduced variants of
	file_utils_uri_to_utf8_filename() and
	file_utils_uri_to_utf8_basename() that use g_filename_display_name()
	and g_filename_display_basename().

	* app/actions/data-commands.c
	* app/actions/documents-commands.c
	* app/actions/file-actions.c
	* app/actions/file-commands.c
	* app/core/gimpimage.c
	* app/core/gimpimagefile.c
	* app/dialogs/file-open-dialog.c
	* app/dialogs/file-open-location-dialog.c
	* app/dialogs/file-save-dialog.c
	* app/dialogs/palette-import-dialog.c
	* app/display/gimpdisplayshell-close.c
	* app/display/gimpdisplayshell-dnd.c
	* app/display/gimpdisplayshell-title.c
	* app/file/file-open.c
	* app/widgets/gimpdnd-xds.c
	* app/widgets/gimpfiledialog.c
	* app/widgets/gimplayertreeview.c
	* app/widgets/gimpthumbbox.c
	* app/widgets/gimptoolbox-dnd.c
	* app/widgets/gimptoolbox.c
	* app/widgets/gimpviewabledialog.c: use the new functions.

	* plug-ins/help/domain.c: use g_filename_display_name().
parent 3c019cac
2005-10-02 Sven Neumann <sven@gimp.org>
* app/file/file-utils.[ch]: introduced variants of
file_utils_uri_to_utf8_filename() and
file_utils_uri_to_utf8_basename() that use g_filename_display_name()
and g_filename_display_basename().
* app/actions/data-commands.c
* app/actions/documents-commands.c
* app/actions/file-actions.c
* app/actions/file-commands.c
* app/core/gimpimage.c
* app/core/gimpimagefile.c
* app/dialogs/file-open-dialog.c
* app/dialogs/file-open-location-dialog.c
* app/dialogs/file-save-dialog.c
* app/dialogs/palette-import-dialog.c
* app/display/gimpdisplayshell-close.c
* app/display/gimpdisplayshell-dnd.c
* app/display/gimpdisplayshell-title.c
* app/file/file-open.c
* app/widgets/gimpdnd-xds.c
* app/widgets/gimpfiledialog.c
* app/widgets/gimplayertreeview.c
* app/widgets/gimpthumbbox.c
* app/widgets/gimptoolbox-dnd.c
* app/widgets/gimptoolbox.c
* app/widgets/gimpviewabledialog.c: use the new functions.
* plug-ins/help/domain.c: use g_filename_display_name().
2005-10-01 Michael Natterer <mitch@gimp.org>
* app/sanity.c (sanity_check_glib): we require 2.8.0 now.
......
......@@ -96,7 +96,7 @@ data_open_as_image_cmd_callback (GtkAction *action,
{
gchar *filename;
filename = file_utils_uri_to_utf8_filename (uri);
filename = file_utils_uri_display_name (uri);
g_message (_("Opening '%s' failed:\n\n%s"),
filename, error->message);
g_clear_error (&error);
......
......@@ -327,7 +327,7 @@ documents_open_image (GimpContext *context,
{
gchar *filename;
filename = file_utils_uri_to_utf8_filename (uri);
filename = file_utils_uri_display_name (uri);
g_message (_("Opening '%s' failed:\n\n%s"),
filename, error->message);
g_clear_error (&error);
......
......@@ -256,8 +256,8 @@ file_actions_last_opened_update (GimpContainer *container,
uri = gimp_object_get_name (GIMP_OBJECT (imagefile));
filename = file_utils_uri_to_utf8_filename (uri);
basename = file_utils_uri_to_utf8_basename (uri);
filename = file_utils_uri_display_name (uri);
basename = file_utils_uri_display_basename (uri);
escaped = gimp_escape_uline (basename);
......
......@@ -167,10 +167,8 @@ file_last_opened_cmd_callback (GtkAction *action,
if (! gimage && status != GIMP_PDB_CANCEL)
{
gchar *filename;
filename =
file_utils_uri_to_utf8_filename (GIMP_OBJECT (imagefile)->name);
gchar *filename =
file_utils_uri_display_name (GIMP_OBJECT (imagefile)->name);
g_message (_("Opening '%s' failed:\n\n%s"),
filename, error->message);
......@@ -224,9 +222,7 @@ file_save_cmd_callback (GtkAction *action,
if (status != GIMP_PDB_SUCCESS &&
status != GIMP_PDB_CANCEL)
{
gchar *filename;
filename = file_utils_uri_to_utf8_filename (uri);
gchar *filename = file_utils_uri_display_name (uri);
g_message (_("Saving '%s' failed:\n\n%s"),
filename, error->message);
......@@ -338,8 +334,8 @@ file_revert_cmd_callback (GtkAction *action,
G_CALLBACK (file_revert_confirm_response),
gdisp);
basename = g_path_get_basename (uri);
filename = file_utils_uri_to_utf8_filename (uri);
basename = file_utils_uri_display_basename (uri);
filename = file_utils_uri_display_name (uri);
gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box,
_("Revert '%s' to '%s'?"),
......@@ -543,7 +539,7 @@ file_revert_confirm_response (GtkWidget *dialog,
{
gchar *filename;
filename = file_utils_uri_to_utf8_filename (uri);
filename = file_utils_uri_display_name (uri);
g_message (_("Reverting to '%s' failed:\n\n%s"),
filename, error->message);
......
......@@ -1069,10 +1069,10 @@ gimp_image_get_description (GimpViewable *viewable,
uri = gimp_image_get_uri (GIMP_IMAGE (gimage));
basename = file_utils_uri_to_utf8_basename (uri);
basename = file_utils_uri_display_basename (uri);
if (tooltip)
*tooltip = file_utils_uri_to_utf8_filename (uri);
*tooltip = file_utils_uri_display_name (uri);
retval = g_strdup_printf ("%s-%d", basename, gimp_image_get_ID (gimage));
......
......@@ -522,7 +522,7 @@ gimp_imagefile_get_description (GimpViewable *viewable,
gchar *filename;
const gchar *desc;
filename = file_utils_uri_to_utf8_filename (thumbnail->image_uri);
filename = file_utils_uri_display_name (thumbnail->image_uri);
desc = gimp_imagefile_get_desc_string (imagefile);
if (desc)
......@@ -536,7 +536,7 @@ gimp_imagefile_get_description (GimpViewable *viewable,
}
}
basename = file_utils_uri_to_utf8_basename (thumbnail->image_uri);
basename = file_utils_uri_display_basename (thumbnail->image_uri);
if (thumbnail->image_width > 0 && thumbnail->image_height > 0)
{
......
......@@ -203,7 +203,7 @@ file_open_dialog_open_image (GtkWidget *open_dialog,
}
else if (status != GIMP_PDB_CANCEL)
{
gchar *filename = file_utils_uri_to_utf8_filename (uri);
gchar *filename = file_utils_uri_display_name (uri);
g_message (_("Opening '%s' failed:\n\n%s"),
filename, error->message);
......@@ -254,7 +254,7 @@ file_open_dialog_open_layer (GtkWidget *open_dialog,
}
else if (status != GIMP_PDB_CANCEL)
{
gchar *filename = file_utils_uri_to_utf8_filename (uri);
gchar *filename = file_utils_uri_display_name (uri);
g_message (_("Opening '%s' failed:\n\n%s"),
filename, error->message);
......
......@@ -196,7 +196,7 @@ file_open_location_response (GtkDialog *dialog,
if (image == NULL && status != GIMP_PDB_CANCEL)
{
gchar *filename = file_utils_uri_to_utf8_filename (uri);
gchar *filename = file_utils_uri_display_name (uri);
g_message (_("Opening '%s' failed:\n\n%s"),
filename, error->message);
......
......@@ -459,7 +459,7 @@ file_save_dialog_save_image (GtkWidget *save_dialog,
if (status != GIMP_PDB_SUCCESS &&
status != GIMP_PDB_CANCEL)
{
gchar *filename = file_utils_uri_to_utf8_filename (uri);
gchar *filename = file_utils_uri_display_name (uri);
g_message (_("Saving '%s' failed:\n\n%s"),
filename, error->message);
......
......@@ -479,7 +479,8 @@ palette_import_image_changed (GimpContext *context,
gchar *basename;
gchar *label;
basename = file_utils_uri_to_utf8_basename (gimp_image_get_uri (gimage));
basename =
file_utils_uri_display_basename (gimp_image_get_uri (gimage));
label = g_strdup_printf ("%s-%d", basename, gimp_image_get_ID (gimage));
g_free (basename);
......
......@@ -118,7 +118,7 @@ gimp_display_shell_close_dialog (GimpDisplayShell *shell,
return;
}
name = file_utils_uri_to_utf8_basename (gimp_image_get_uri (gimage));
name = file_utils_uri_display_basename (gimp_image_get_uri (gimage));
title = g_strdup_printf (_("Close %s"), name);
g_free (name);
......@@ -191,7 +191,7 @@ gimp_display_shell_close_name_changed (GimpImage *image,
GtkWidget *window = gtk_widget_get_toplevel (GTK_WIDGET (box));
gchar *name;
name = file_utils_uri_to_utf8_basename (gimp_image_get_uri (image));
name = file_utils_uri_display_basename (gimp_image_get_uri (image));
if (window)
{
......
......@@ -443,7 +443,7 @@ gimp_display_shell_drop_uri_list (GtkWidget *widget,
}
else if (status != GIMP_PDB_CANCEL)
{
gchar *filename = file_utils_uri_to_utf8_filename (uri);
gchar *filename = file_utils_uri_display_name (uri);
g_message (_("Opening '%s' failed:\n\n%s"),
filename, error->message);
......
......@@ -184,7 +184,7 @@ gimp_display_shell_format_title (GimpDisplayShell *shell,
const gchar *uri = gimp_image_get_uri (image);
gchar *basename;
basename = file_utils_uri_to_utf8_basename (uri);
basename = file_utils_uri_display_basename (uri);
i += print (title, title_len, i, "%s", basename);
......@@ -197,7 +197,7 @@ gimp_display_shell_format_title (GimpDisplayShell *shell,
gchar *filename;
const gchar *uri = gimp_image_get_uri (image);
filename = file_utils_uri_to_utf8_filename (uri);
filename = file_utils_uri_display_name (uri);
i += print (title, title_len, i, "%s", filename);
......
......@@ -399,11 +399,10 @@ file_open_layer (Gimp *gimp,
if (item)
{
gchar *basename;
gchar *basename = file_utils_uri_display_basename (uri);
new_layer = GIMP_LAYER (item);
basename = file_utils_uri_to_utf8_basename (uri);
gimp_object_set_name (GIMP_OBJECT (new_layer), basename);
g_free (basename);
......
......@@ -265,6 +265,35 @@ file_utils_find_proc_by_extension (GSList *procs,
}
gchar *
file_utils_uri_to_utf8_filename (const gchar *uri)
{
g_return_val_if_fail (uri != NULL, NULL);
if (g_str_has_prefix (uri, "file:"))
{
gchar *filename = file_utils_filename_from_uri (uri);
if (filename)
{
GError *error = NULL;
gchar *utf8;
utf8 = g_filename_to_utf8 (filename, -1, NULL, NULL, &error);
g_free (filename);
if (utf8)
return utf8;
g_warning ("%s: cannot convert filename to UTF-8: %s",
G_STRLOC, error->message);
g_error_free (error);
}
}
return g_strdup (uri);
}
static gchar *
file_utils_uri_to_utf8_basename (const gchar *uri)
{
gchar *filename;
......@@ -297,7 +326,7 @@ file_utils_uri_to_utf8_basename (const gchar *uri)
}
gchar *
file_utils_uri_to_utf8_filename (const gchar *uri)
file_utils_uri_display_basename (const gchar *uri)
{
g_return_val_if_fail (uri != NULL, NULL);
......@@ -307,25 +336,39 @@ file_utils_uri_to_utf8_filename (const gchar *uri)
if (filename)
{
GError *error = NULL;
gchar *utf8;
gchar *basename = g_filename_display_basename (filename);
utf8 = g_filename_to_utf8 (filename, -1, NULL, NULL, &error);
g_free (filename);
if (utf8)
return utf8;
return basename;
}
}
g_warning ("%s: cannot convert filename to UTF-8: %s",
G_STRLOC, error->message);
g_error_free (error);
return file_utils_uri_to_utf8_basename (uri);
}
gchar *
file_utils_uri_display_name (const gchar *uri)
{
g_return_val_if_fail (uri != NULL, NULL);
if (g_str_has_prefix (uri, "file:"))
{
gchar *filename = file_utils_filename_from_uri (uri);
if (filename)
{
gchar *name = g_filename_display_name (filename);
g_free (filename);
return name;
}
}
return g_strdup (uri);
}
/* private functions */
static PlugInProcDef *
......
......@@ -27,9 +27,11 @@ gchar * file_utils_filename_to_uri (GSList *procs,
GError **error);
gchar * file_utils_filename_from_uri (const gchar *uri);
gchar * file_utils_uri_to_utf8_basename (const gchar *uri);
gchar * file_utils_uri_to_utf8_filename (const gchar *uri);
gchar * file_utils_uri_display_basename (const gchar *uri);
gchar * file_utils_uri_display_name (const gchar *uri);
PlugInProcDef * file_utils_find_proc (GSList *procs,
const gchar *filename);
PlugInProcDef * file_utils_find_proc_by_extension (GSList *procs,
......
......@@ -153,7 +153,7 @@ gimp_dnd_xds_save_image (GdkDragContext *context,
if (error)
{
gchar *filename = file_utils_uri_to_utf8_filename (uri);
gchar *filename = file_utils_uri_display_name (uri);
g_message (_("Saving '%s' failed:\n\n%s"),
filename, error->message);
......
......@@ -449,7 +449,7 @@ gimp_file_overwrite_dialog (GtkWidget *parent,
GTK_RESPONSE_CANCEL,
-1);
filename = file_utils_uri_to_utf8_filename (uri);
filename = file_utils_uri_display_name (uri);
gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box,
_("A file named '%s' already exists."),
filename);
......@@ -726,7 +726,7 @@ gimp_file_dialog_proc_changed (GimpFileProcView *view,
gtk_file_chooser_set_uri (chooser, s->str);
basename = file_utils_uri_to_utf8_basename (s->str);
basename = file_utils_uri_display_basename (s->str);
gtk_file_chooser_set_current_name (chooser, basename);
g_free (basename);
......
......@@ -759,7 +759,7 @@ gimp_layer_tree_view_drop_uri_list (GimpContainerTreeView *view,
}
else if (status != GIMP_PDB_CANCEL)
{
gchar *filename = file_utils_uri_to_utf8_filename (uri);
gchar *filename = file_utils_uri_display_name (uri);
g_message (_("Opening '%s' failed:\n\n%s"),
filename, error->message);
......
......@@ -481,9 +481,8 @@ gimp_thumb_box_set_uri (GimpThumbBox *box,
if (uri)
{
gchar *basename;
gchar *basename = file_utils_uri_display_basename (uri);
basename = file_utils_uri_to_utf8_basename (uri);
gtk_label_set_text (GTK_LABEL (box->filename), basename);
g_free (basename);
}
......@@ -707,7 +706,7 @@ gimp_thumb_box_create_thumbnail (GimpThumbBox *box,
thumb = box->imagefile->thumbnail;
basename = file_utils_uri_to_utf8_basename (uri);
basename = file_utils_uri_display_basename (uri);
gtk_label_set_text (GTK_LABEL (box->filename), basename);
g_free (basename);
......
......@@ -152,7 +152,7 @@ gimp_toolbox_drop_uri_list (GtkWidget *widget,
if (! gimage && status != GIMP_PDB_CANCEL)
{
gchar *filename = file_utils_uri_to_utf8_filename (uri);
gchar *filename = file_utils_uri_display_name (uri);
g_message (_("Opening '%s' failed:\n\n%s"),
filename, error->message);
......
......@@ -939,7 +939,7 @@ toolbox_paste_received (GtkClipboard *clipboard,
if (! image && status != GIMP_PDB_CANCEL)
{
gchar *filename = file_utils_uri_to_utf8_filename (copy);
gchar *filename = file_utils_uri_display_name (copy);
g_message (_("Opening '%s' failed:\n\n%s"),
filename, error->message);
......
......@@ -346,7 +346,7 @@ gimp_viewable_dialog_name_changed (GimpObject *object,
uri = gimp_image_get_uri (gimp_item_get_image (GIMP_ITEM (object)));
tmp = name;
basename = file_utils_uri_to_utf8_basename (uri);
basename = file_utils_uri_display_basename (uri);
name = g_strdup_printf ("%s-%d (%s)",
tmp,
gimp_item_get_ID (GIMP_ITEM (object)),
......
......@@ -683,7 +683,7 @@ domain_error_set_message (GError **error,
{
if (error && *error)
{
gchar *name = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
gchar *name = g_filename_display_name (filename);
gchar *msg = g_strdup_printf (format, name, (*error)->message);
g_free (name);
......
......@@ -683,7 +683,7 @@ domain_error_set_message (GError **error,
{
if (error && *error)
{
gchar *name = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
gchar *name = g_filename_display_name (filename);
gchar *msg = g_strdup_printf (format, name, (*error)->message);
g_free (name);
......
......@@ -683,7 +683,7 @@ domain_error_set_message (GError **error,
{
if (error && *error)
{
gchar *name = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
gchar *name = g_filename_display_name (filename);
gchar *msg = g_strdup_printf (format, name, (*error)->message);
g_free (name);
......
......@@ -683,7 +683,7 @@ domain_error_set_message (GError **error,
{
if (error && *error)
{
gchar *name = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
gchar *name = g_filename_display_name (filename);
gchar *msg = g_strdup_printf (format, name, (*error)->message);
g_free (name);
......
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