talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 126ff4dcbc912d839ba9e0340857d22abf71e0ef
parent d2578f7adcf14a288a101e94f048c8215e3a200b
Author: Andrej Kacian <ticho@claws-mail.org>
Date:   Sun, 22 Oct 2017 17:27:08 +0200

Made Fancy's custom stylesheet pref work on Windows

Diffstat:
Msrc/plugins/fancy/fancy_prefs.c | 8++++++++
Msrc/plugins/fancy/fancy_viewer.c | 23+++++++++++++++++++++--
2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/src/plugins/fancy/fancy_prefs.c b/src/plugins/fancy/fancy_prefs.c @@ -442,7 +442,15 @@ static void save_fancy_prefs_page(PrefsPage *page) fancy_prefs.enable_proxy = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(prefs_page->proxy_checkbox)); fancy_prefs.proxy_str = pref_get_pref_from_entry(GTK_ENTRY(prefs_page->proxy_str)); +#ifdef G_OS_WIN32 + /* pref_get_pref_from_entry() escapes the backslashes in strings, + * we do not want that, since this entry contains a Windows path. + * Let's just strdup it. */ + fancy_prefs.stylesheet = g_strdup(gtk_entry_get_text( + GTK_ENTRY(prefs_page->stylesheet))); +#else fancy_prefs.stylesheet = pref_get_pref_from_entry(GTK_ENTRY(prefs_page->stylesheet)); +#endif save_fancy_prefs(page); } diff --git a/src/plugins/fancy/fancy_viewer.c b/src/plugins/fancy/fancy_viewer.c @@ -148,10 +148,29 @@ static void fancy_set_defaults(FancyViewer *viewer) viewer->override_prefs_plugins = fancy_prefs.enable_plugins; viewer->override_prefs_java = fancy_prefs.enable_java; - gchar *tmp = g_uri_escape_string(fancy_prefs.stylesheet, "/", TRUE); + gchar *tmp; +#ifdef G_OS_WIN32 + /* Replace backslashes with forward slashes, since we'll be + * using this string in an URI. */ + gchar *tmp2 = g_strdup(fancy_prefs.stylesheet); + gchar *c; + for (c = tmp2; *c != '\0'; c++) { + if (*c == '\\') + *c = '/'; + } + + /* Escape string for use in an URI, keeping dir separators + * and colon for Windows drive name ("C:") intact. */ + tmp = g_uri_escape_string(tmp2, "/:", TRUE); + g_free(tmp2); +#else + /* Escape string for use in an URI, keeping dir separators + * intact. */ + tmp = g_uri_escape_string(fancy_prefs.stylesheet, "/", TRUE); +#endif viewer->override_stylesheet = g_strconcat("file://", tmp, NULL); g_free(tmp); - debug_print("Passing '%s' stylesheet URI to Webkit\n", + debug_print("Passing '%s' as stylesheet URI to Webkit\n", viewer->override_stylesheet); g_signal_handlers_block_by_func(G_OBJECT(viewer->enable_images),