Unverified Kaydet (Commit) 2c8f7549 authored tarafından Enrico Tröger's avatar Enrico Tröger Kaydeden (comit) GitHub

Merge pull request #1667 from eht16/issue1018_win_execute_builtin_path

Use utils_get_uri_file_prefix() as file URI prefix
...@@ -1237,13 +1237,14 @@ static void on_build_menu_item(GtkWidget *w, gpointer user_data) ...@@ -1237,13 +1237,14 @@ static void on_build_menu_item(GtkWidget *w, gpointer user_data)
bc = get_build_cmd(doc, grp, cmd, NULL); bc = get_build_cmd(doc, grp, cmd, NULL);
if (bc != NULL && strcmp(bc->command, "builtin") == 0) if (bc != NULL && strcmp(bc->command, "builtin") == 0)
{ {
const gchar *uri_file_prefix;
gchar *uri; gchar *uri;
if (doc == NULL) if (doc == NULL)
return; return;
uri = g_strconcat("file:///", g_path_skip_root(doc->file_name), NULL); uri_file_prefix = utils_get_uri_file_prefix();
uri = g_strconcat(uri_file_prefix, doc->file_name, NULL);
utils_open_browser(uri); utils_open_browser(uri);
g_free(uri); g_free(uri);
} }
else else
build_run_cmd(doc, cmd); build_run_cmd(doc, cmd);
......
...@@ -1688,6 +1688,17 @@ gboolean utils_spawn_async(const gchar *dir, gchar **argv, gchar **env, GSpawnFl ...@@ -1688,6 +1688,17 @@ gboolean utils_spawn_async(const gchar *dir, gchar **argv, gchar **env, GSpawnFl
} }
/* Returns "file:///" on Windows, "file://" everywhere else */
const gchar *utils_get_uri_file_prefix(void)
{
#ifdef G_OS_WIN32
return "file:///";
#else
return "file://";
#endif
}
/* Retrieves the path for the given URI. /* Retrieves the path for the given URI.
* It returns: * It returns:
* - the path which was determined by g_filename_from_uri() or GIO * - the path which was determined by g_filename_from_uri() or GIO
...@@ -1893,16 +1904,13 @@ GSList *utils_get_config_files(const gchar *subdir) ...@@ -1893,16 +1904,13 @@ GSList *utils_get_config_files(const gchar *subdir)
* an anchor link, e.g. "#some_anchor". */ * an anchor link, e.g. "#some_anchor". */
gchar *utils_get_help_url(const gchar *suffix) gchar *utils_get_help_url(const gchar *suffix)
{ {
gint skip;
gchar *uri; gchar *uri;
const gchar *uri_file_prefix = utils_get_uri_file_prefix();
gint skip = strlen(uri_file_prefix);
uri = g_strconcat(uri_file_prefix, app->docdir, "/index.html", NULL);
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
skip = 8;
uri = g_strconcat("file:///", app->docdir, "/index.html", NULL);
g_strdelimit(uri, "\\", '/'); /* replace '\\' by '/' */ g_strdelimit(uri, "\\", '/'); /* replace '\\' by '/' */
#else
skip = 7;
uri = g_strconcat("file://", app->docdir, "/index.html", NULL);
#endif #endif
if (! g_file_test(uri + skip, G_FILE_TEST_IS_REGULAR)) if (! g_file_test(uri + skip, G_FILE_TEST_IS_REGULAR))
......
...@@ -309,6 +309,7 @@ gboolean utils_str_has_upper(const gchar *str); ...@@ -309,6 +309,7 @@ gboolean utils_str_has_upper(const gchar *str);
gint utils_is_file_writable(const gchar *locale_filename); gint utils_is_file_writable(const gchar *locale_filename);
const gchar *utils_get_uri_file_prefix(void);
gchar *utils_get_path_from_uri(const gchar *uri); gchar *utils_get_path_from_uri(const gchar *uri);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment