From d44e0ee750dd8677ef6979324ef2edc62015f426 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Tue, 9 Apr 2019 17:32:53 +0100 Subject: [PATCH] When displaying paths on MS Windows, make them look normal Change the forward slashes to back slashes as that is normal for paths in MS Windows. --- gnucash/gnome/dialog-trans-assoc.c | 9 ++++++++- gnucash/gnome/gnc-split-reg.c | 8 +++++++- gnucash/register/ledger-core/split-register-model.c | 6 ++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/gnucash/gnome/dialog-trans-assoc.c b/gnucash/gnome/dialog-trans-assoc.c index fbb9a00aec..f835e8664b 100644 --- a/gnucash/gnome/dialog-trans-assoc.c +++ b/gnucash/gnome/dialog-trans-assoc.c @@ -170,7 +170,12 @@ convert_uri_to_unescaped (AssocDialog *assoc_dialog, const gchar *uri, gchar *sc file_path = convert_uri_to_filename (assoc_dialog, uri, scheme); if (file_path) + { uri_u = g_uri_unescape_string (file_path, NULL); +#ifdef G_OS_WIN32 // make path look like a traditional windows path + uri_u = g_strdelimit (uri_u, "/", '\\'); +#endif + } else uri_u = g_uri_unescape_string (uri, NULL); @@ -489,7 +494,9 @@ gnc_assoc_dialog_create (GtkWindow *parent, AssocDialog *assoc_dialog) gchar *path_head_ue_str = g_uri_unescape_string (assoc_dialog->path_head, NULL); gchar *path_head_str = gnc_uri_get_path (path_head_ue_str); gchar *path_head_label; - +#ifdef G_OS_WIN32 // make path look like a traditional windows path + path_head_str = g_strdelimit (path_head_str, "/", '\\'); +#endif // test for current folder being present if (g_file_test (path_head_str, G_FILE_TEST_IS_DIR)) path_head_label = g_strconcat (_("Path head for files is, "), path_head_str, NULL); diff --git a/gnucash/gnome/gnc-split-reg.c b/gnucash/gnome/gnc-split-reg.c index 84071323c5..5f7f0767c7 100644 --- a/gnucash/gnome/gnc-split-reg.c +++ b/gnucash/gnome/gnc-split-reg.c @@ -1083,7 +1083,13 @@ gsr_default_associate_handler_file (GNCSplitReg *gsr, Transaction *trans, gboole GtkWidget *label; gchar *file_uri_u = g_uri_unescape_string (file_uri, NULL); gchar *filename = gnc_uri_get_path (file_uri_u); - gchar *uri_label = g_strconcat (_("Existing Association is '"), filename, "'", NULL); + gchar *uri_label; + +#ifdef G_OS_WIN32 // make path look like a traditional windows path + filename = g_strdelimit (filename, "/", '\\'); +#endif + uri_label = g_strconcat (_("Existing Association is '"), filename, "'", NULL); + PINFO("Path head: '%s', URI: '%s', Filename: '%s'", path_head, uri, filename); label = gtk_label_new (uri_label); gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER(dialog), label); diff --git a/gnucash/register/ledger-core/split-register-model.c b/gnucash/register/ledger-core/split-register-model.c index 287891f7d3..f05dcd118c 100644 --- a/gnucash/register/ledger-core/split-register-model.c +++ b/gnucash/register/ledger-core/split-register-model.c @@ -574,6 +574,11 @@ gnc_split_register_get_associate_tooltip (VirtualLocation virt_loc, if (gnc_uri_is_file_scheme (scheme)) // absolute path file_path = gnc_uri_get_path (uri); +#ifdef G_OS_WIN32 // make path look like a traditional windows path + if (file_path) + file_path = g_strdelimit (file_path, "/", '\\'); +#endif + g_free (scheme); if (!file_path) @@ -583,6 +588,7 @@ gnc_split_register_get_associate_tooltip (VirtualLocation virt_loc, gchar *file_uri_u = g_uri_unescape_string (file_path, NULL); const gchar *filename = gnc_uri_get_path (file_uri_u); g_free (file_uri_u); + g_free (file_path); return g_strdup (filename); } }