2 * History.c: Implements file menu file history
5 * Mike Kestner (mkestner@ameritech.net)
8 #include <gnumeric-config.h>
9 #include <glib/gi18n-lib.h>
10 #include <goffice/goffice.h>
16 * Returns a newly allocated string containing the base name of the file
17 * with any .gnumeric extension stripped off.
20 gnm_history_item_label (gchar
const *uri
, int accel_number
)
22 GString
*res
= g_string_new (NULL
);
25 basename
= go_basename_from_uri (uri
);
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 ");
38 g_string_append_printf (res
, "%d ", accel_number
);
40 /* Underscores need to be doubled. */
41 for (tmp
= basename
; *tmp
; tmp
++) {
43 g_string_append_c (res
, '_');
44 g_string_append_c (res
, *tmp
);
48 return g_string_free (res
, FALSE
);