plug-ins/help/domain.c same trick here; should allow to work with help

2005-02-07  Sven Neumann  <sven@gimp.org>

	* 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.
This commit is contained in:
Sven Neumann 2005-02-07 18:06:17 +00:00 committed by Sven Neumann
parent 2f98bfd191
commit 060028ec55
6 changed files with 196 additions and 5 deletions

View File

@ -1,3 +1,9 @@
2005-02-07 Sven Neumann <sven@gimp.org>
* 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 <sven@gimp.org>
* app/dialogs/file-open-dialog.c

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}