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
);
26 basename
= go_basename_from_uri (uri
);
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 ");
40 g_string_append_printf (res
, "%d ", accel_number
);
42 /* Underscores need to be doubled. */
43 for (tmp
= basename
; *tmp
; tmp
++) {
45 g_string_append_c (res
, '_');
46 g_string_append_c (res
, *tmp
);
50 return g_string_free (res
, FALSE
);