Update Spanish translation
[gnumeric.git] / src / history.c
blob556af219b3b902be1596efef9761525c3cdddd41
1 /*
2 * History.c: Implements file menu file history
4 * Author:
5 * Mike Kestner (mkestner@ameritech.net)
7 */
8 #include <gnumeric-config.h>
9 #include <glib/gi18n-lib.h>
10 #include <goffice/goffice.h>
11 #include <gnumeric.h>
12 #include <history.h>
13 #include <string.h>
16 * Returns a newly allocated string containing the base name of the file
17 * with any .gnumeric extension stripped off.
19 gchar *
20 gnm_history_item_label (gchar const *uri, int accel_number)
22 GString *res = g_string_new (NULL);
23 char *basename, *tmp;
25 basename = go_basename_from_uri (uri);
26 if (basename == NULL)
27 basename = g_strdup ("(invalid file name)");
29 /* Remove .gnumeric, if present. */
30 if (g_str_has_suffix (basename, ".gnumeric"))
31 basename[strlen (basename) - 9] = 0;
33 if (accel_number <= 9)
34 g_string_append_printf (res, "_%d ", accel_number);
35 else if (accel_number == 10)
36 g_string_append (res, "1_0 ");
37 else
38 g_string_append_printf (res, "%d ", accel_number);
40 /* Underscores need to be doubled. */
41 for (tmp = basename; *tmp; tmp++) {
42 if (*tmp == '_')
43 g_string_append_c (res, '_');
44 g_string_append_c (res, *tmp);
46 g_free (basename);
48 return g_string_free (res, FALSE);