diff --git a/ChangeLog b/ChangeLog index 89c7fae14d..fab3e92f7c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-02-07 Sven Neumann + + * plug-ins/help/domain.c + * plug-ins/helpbrowser/dialog.c: same trick here; should allow to + work with help files installed in an UNC path. + 2005-02-07 Sven Neumann * app/dialogs/file-open-dialog.c diff --git a/plug-ins/help/domain.c b/plug-ins/help/domain.c index fb1c9be1b4..1e9c5b2cb4 100644 --- a/plug-ins/help/domain.c +++ b/plug-ins/help/domain.c @@ -81,6 +81,8 @@ static void domain_error_set_message (GError **error, const gchar *format, const gchar *filename); +static gchar help_filename_from_uri (const gchar *uri); + /* private variables */ @@ -392,7 +394,7 @@ domain_locale_parse (HelpDomain *domain, } if (! domain->help_root) - domain->help_root = g_filename_from_uri (domain->help_uri, NULL, NULL); + domain->help_root = help_filename_from_uri (domain->help_uri); if (! domain->help_root) { @@ -690,3 +692,38 @@ domain_error_set_message (GError **error, (*error)->message = msg; } } + +static gchar +help_filename_from_uri (const gchar *uri) +{ + gchar *filename; + gchar *hostname; + + g_return_val_if_fail (uri != NULL, NULL); + + filename = g_filename_from_uri (uri, &hostname, NULL); + + if (!filename) + return NULL; + + if (hostname) + { + /* we have a file: URI with a hostname */ +#ifdef G_OS_WIN32 + /* on Win32, create a valid UNC path and use it as the filename */ + + gchar *tmp = g_build_filename ("//", hostname, filename, NULL); + + g_free (filename); + filename = tmp; +#else + /* otherwise return NULL, caller should use URI then */ + g_free (filename); + filename = NULL; +#endif + + g_free (hostname); + } + + return filename; +} diff --git a/plug-ins/help/gimphelp.c b/plug-ins/help/gimphelp.c index fb1c9be1b4..1e9c5b2cb4 100644 --- a/plug-ins/help/gimphelp.c +++ b/plug-ins/help/gimphelp.c @@ -81,6 +81,8 @@ static void domain_error_set_message (GError **error, const gchar *format, const gchar *filename); +static gchar help_filename_from_uri (const gchar *uri); + /* private variables */ @@ -392,7 +394,7 @@ domain_locale_parse (HelpDomain *domain, } if (! domain->help_root) - domain->help_root = g_filename_from_uri (domain->help_uri, NULL, NULL); + domain->help_root = help_filename_from_uri (domain->help_uri); if (! domain->help_root) { @@ -690,3 +692,38 @@ domain_error_set_message (GError **error, (*error)->message = msg; } } + +static gchar +help_filename_from_uri (const gchar *uri) +{ + gchar *filename; + gchar *hostname; + + g_return_val_if_fail (uri != NULL, NULL); + + filename = g_filename_from_uri (uri, &hostname, NULL); + + if (!filename) + return NULL; + + if (hostname) + { + /* we have a file: URI with a hostname */ +#ifdef G_OS_WIN32 + /* on Win32, create a valid UNC path and use it as the filename */ + + gchar *tmp = g_build_filename ("//", hostname, filename, NULL); + + g_free (filename); + filename = tmp; +#else + /* otherwise return NULL, caller should use URI then */ + g_free (filename); + filename = NULL; +#endif + + g_free (hostname); + } + + return filename; +} diff --git a/plug-ins/help/gimphelpdomain.c b/plug-ins/help/gimphelpdomain.c index fb1c9be1b4..1e9c5b2cb4 100644 --- a/plug-ins/help/gimphelpdomain.c +++ b/plug-ins/help/gimphelpdomain.c @@ -81,6 +81,8 @@ static void domain_error_set_message (GError **error, const gchar *format, const gchar *filename); +static gchar help_filename_from_uri (const gchar *uri); + /* private variables */ @@ -392,7 +394,7 @@ domain_locale_parse (HelpDomain *domain, } if (! domain->help_root) - domain->help_root = g_filename_from_uri (domain->help_uri, NULL, NULL); + domain->help_root = help_filename_from_uri (domain->help_uri); if (! domain->help_root) { @@ -690,3 +692,38 @@ domain_error_set_message (GError **error, (*error)->message = msg; } } + +static gchar +help_filename_from_uri (const gchar *uri) +{ + gchar *filename; + gchar *hostname; + + g_return_val_if_fail (uri != NULL, NULL); + + filename = g_filename_from_uri (uri, &hostname, NULL); + + if (!filename) + return NULL; + + if (hostname) + { + /* we have a file: URI with a hostname */ +#ifdef G_OS_WIN32 + /* on Win32, create a valid UNC path and use it as the filename */ + + gchar *tmp = g_build_filename ("//", hostname, filename, NULL); + + g_free (filename); + filename = tmp; +#else + /* otherwise return NULL, caller should use URI then */ + g_free (filename); + filename = NULL; +#endif + + g_free (hostname); + } + + return filename; +} diff --git a/plug-ins/help/gimphelplocale.c b/plug-ins/help/gimphelplocale.c index fb1c9be1b4..1e9c5b2cb4 100644 --- a/plug-ins/help/gimphelplocale.c +++ b/plug-ins/help/gimphelplocale.c @@ -81,6 +81,8 @@ static void domain_error_set_message (GError **error, const gchar *format, const gchar *filename); +static gchar help_filename_from_uri (const gchar *uri); + /* private variables */ @@ -392,7 +394,7 @@ domain_locale_parse (HelpDomain *domain, } if (! domain->help_root) - domain->help_root = g_filename_from_uri (domain->help_uri, NULL, NULL); + domain->help_root = help_filename_from_uri (domain->help_uri); if (! domain->help_root) { @@ -690,3 +692,38 @@ domain_error_set_message (GError **error, (*error)->message = msg; } } + +static gchar +help_filename_from_uri (const gchar *uri) +{ + gchar *filename; + gchar *hostname; + + g_return_val_if_fail (uri != NULL, NULL); + + filename = g_filename_from_uri (uri, &hostname, NULL); + + if (!filename) + return NULL; + + if (hostname) + { + /* we have a file: URI with a hostname */ +#ifdef G_OS_WIN32 + /* on Win32, create a valid UNC path and use it as the filename */ + + gchar *tmp = g_build_filename ("//", hostname, filename, NULL); + + g_free (filename); + filename = tmp; +#else + /* otherwise return NULL, caller should use URI then */ + g_free (filename); + filename = NULL; +#endif + + g_free (hostname); + } + + return filename; +} diff --git a/plug-ins/helpbrowser/dialog.c b/plug-ins/helpbrowser/dialog.c index 7c907d4ea6..4f13b02b00 100644 --- a/plug-ins/helpbrowser/dialog.c +++ b/plug-ins/helpbrowser/dialog.c @@ -105,6 +105,8 @@ static void history_add (GtkComboBox *combo, static gboolean has_case_prefix (const gchar *haystack, const gchar *needle); +static gchar filename_from_uri (const gchar *uri); + /* private variables */ @@ -548,7 +550,7 @@ request_url (HtmlDocument *doc, if (! abs) return TRUE; - filename = g_filename_from_uri (abs, NULL, NULL); + filename = filename_from_uri (abs); g_free (abs); if (filename) @@ -702,3 +704,38 @@ has_case_prefix (const gchar *haystack, const gchar *needle) return (*n == '\0'); } + +static gchar +filename_from_uri (const gchar *uri) +{ + gchar *filename; + gchar *hostname; + + g_return_val_if_fail (uri != NULL, NULL); + + filename = g_filename_from_uri (uri, &hostname, NULL); + + if (!filename) + return NULL; + + if (hostname) + { + /* we have a file: URI with a hostname */ +#ifdef G_OS_WIN32 + /* on Win32, create a valid UNC path and use it as the filename */ + + gchar *tmp = g_build_filename ("//", hostname, filename, NULL); + + g_free (filename); + filename = tmp; +#else + /* otherwise return NULL, caller should use URI then */ + g_free (filename); + filename = NULL; +#endif + + g_free (hostname); + } + + return filename; +}