new function which does the opposite of gimp_strip_uline().

2004-04-29  Michael Natterer  <mitch@gimp.org>

	* libgimpbase/gimputils.[ch] (gimp_escape_uline): new function
	which does the opposite of gimp_strip_uline().

	* app/actions/file-actions.c (file_actions_last_opened_update):
	escape ulines in filenames so they don't end up as mnemonics.
	Spotted by Pedro Gimeno.
This commit is contained in:
Michael Natterer 2004-04-29 16:47:53 +00:00 committed by Michael Natterer
parent 3d293ea0f7
commit d79ed2a040
4 changed files with 59 additions and 2 deletions

View File

@ -1,3 +1,12 @@
2004-04-29 Michael Natterer <mitch@gimp.org>
* libgimpbase/gimputils.[ch] (gimp_escape_uline): new function
which does the opposite of gimp_strip_uline().
* app/actions/file-actions.c (file_actions_last_opened_update):
escape ulines in filenames so they don't end up as mnemonics.
Spotted by Pedro Gimeno.
2004-04-29 Manish Singh <yosh@gimp.org>
* plug-ins/pygimp/plug-ins/py-slice.py: Quick fix to make uppercase

View File

@ -20,6 +20,7 @@
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "actions-types.h"
@ -240,20 +241,25 @@ file_actions_last_opened_update (GimpContainer *container,
const gchar *uri;
gchar *filename;
gchar *basename;
gchar *escaped;
uri = gimp_object_get_name (GIMP_OBJECT (imagefile));
filename = file_utils_uri_to_utf8_filename (uri);
basename = file_utils_uri_to_utf8_basename (uri);
escaped = gimp_escape_uline (basename);
g_free (basename);
g_object_set (G_OBJECT (action),
"label", basename,
"label", escaped,
"tooltip", filename,
"visible", TRUE,
NULL);
g_free (filename);
g_free (basename);
g_free (escaped);
g_object_set_data (G_OBJECT (action),
"gimp-imagefile", imagefile);

View File

@ -331,3 +331,44 @@ gimp_strip_uline (const gchar *str)
return escaped;
}
/**
* gimp_escape_uline:
* @str: Underline infested string (or %NULL)
*
* This function returns a copy of @str with all underline converted
* to two adjacent underlines. This comes in handy when needing to display
* strings with underlines (like filenames) in a place that would convert
* them to mnemonics.
*
* Return value: A (possibly escaped) copy of @str which should be
* freed using g_free() when it is not needed any longer.
**/
gchar *
gimp_escape_uline (const gchar *str)
{
gchar *escaped;
gchar *p;
gint n_ulines = 0;
if (! str)
return NULL;
for (p = (gchar *) str; *p; p++)
if (*p == '_')
n_ulines++;
p = escaped = g_malloc (strlen (str) + n_ulines + 1);
while (*str)
{
if (*str == '_')
*p++ = '_';
*p++ = *str++;
}
*p = '\0';
return escaped;
}

View File

@ -32,6 +32,7 @@ const gchar * gimp_filename_to_utf8 (const gchar *filename);
gchar * gimp_memsize_to_string (guint64 memsize);
gchar * gimp_strip_uline (const gchar *str);
gchar * gimp_escape_uline (const gchar *str);
#endif /* __GIMP_UTILS_H__ */