From 470d54ff9a0258c8b0ad4d2c0985d5ffbfca0171 Mon Sep 17 00:00:00 2001 From: Dave Peticolas Date: Sun, 14 May 2000 23:00:17 +0000 Subject: [PATCH] Fix underscore bug in file history. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2318 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/gnome/file-history.c | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/gnome/file-history.c b/src/gnome/file-history.c index 2ad34aeb54..9e55549210 100644 --- a/src/gnome/file-history.c +++ b/src/gnome/file-history.c @@ -161,13 +161,18 @@ gnc_history_update_menu() GnomeApp *app; GnomeUIInfo *menu; char *path; + char *file; + char *name; + char *p, *q; + int count; int i, n; app = GNOME_APP(gnc_get_ui_data()); if (app == NULL) return; - gnome_app_remove_menu_range(app, _("_File/"), 7, 1+num_menu_entries); + gnome_app_remove_menu_range(app, GNOME_MENU_FILE_PATH, + 7, 1 + num_menu_entries); if(history_list == NULL) __gnc_history_get_list(); @@ -183,9 +188,31 @@ gnc_history_update_menu() for(i = 1; i <= n; i++) { (menu+i)->type = GNOME_APP_UI_ITEM; - (menu+i)->label = g_strdup_printf("_%d. %s", i, - (char *)g_slist_nth_data(history_list, - i-1)); + + /* get the file name */ + file = g_slist_nth_data(history_list, i - 1); + if (file == NULL) + file = ""; + + /* count the underscores */ + count = 0; + for (p = file; *p != '\0'; p++) + if (*p == '_') + count++; + + /* make the name, doubling the underscores to prevent underlining */ + name = g_new(char, strlen(file) + count + 1); + for (p = file, q = name; *p != '\0'; p++) { + *q++ = *p; + if (*p == '_') + *q++ = '_'; + } + *q = '\0'; + + (menu+i)->label = g_strdup_printf("_%d. %s", i, name); + + g_free(name); + (menu+i)->hint = NULL; (menu+i)->moreinfo = (gpointer)__gnc_history_file_cb;