Introspection: fix problems with boxed type.
[gnumeric.git] / src / history.c
blobe3d85bd734c35ae6d2caa45fd55748e3fa53a065
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;
24 int len;
26 basename = go_basename_from_uri (uri);
27 if (basename == NULL)
28 basename = g_strdup ("(invalid file name)");
30 /* Remove .gnumeric, if present. */
31 len = strlen (basename);
32 if (len > 9 && strcmp (basename + len - 9, ".gnumeric") == 0)
33 basename[len - 9] = 0;
35 if (accel_number <= 9)
36 g_string_append_printf (res, "_%d ", accel_number);
37 else if (accel_number == 10)
38 g_string_append (res, "1_0 ");
39 else
40 g_string_append_printf (res, "%d ", accel_number);
42 /* Underscores need to be doubled. */
43 for (tmp = basename; *tmp; tmp++) {
44 if (*tmp == '_')
45 g_string_append_c (res, '_');
46 g_string_append_c (res, *tmp);
48 g_free (basename);
50 return g_string_free (res, FALSE);