Find res in executable or build folder
We can drop the versioned filename.
This commit is contained in:
parent
af315513a8
commit
4a4887b511
6 changed files with 75 additions and 33 deletions
|
@ -27,7 +27,7 @@ formhistory_construct_popup_gui (FormHistoryPriv* priv)
|
|||
guint i;
|
||||
gchar* file;
|
||||
|
||||
file = sokoke_find_data_filename ("autosuggestcontrol.js", TRUE);
|
||||
file = midori_app_find_res_filename ("autosuggestcontrol.js");
|
||||
if (!g_file_get_contents (file, &autosuggest, NULL, NULL))
|
||||
{
|
||||
g_free (file);
|
||||
|
@ -35,7 +35,7 @@ formhistory_construct_popup_gui (FormHistoryPriv* priv)
|
|||
}
|
||||
g_strchomp (autosuggest);
|
||||
|
||||
katze_assign (file, sokoke_find_data_filename ("autosuggestcontrol.css", TRUE));
|
||||
katze_assign (file, midori_app_find_res_filename ("autosuggestcontrol.css"));
|
||||
if (!g_file_get_contents (file, &style, NULL, NULL))
|
||||
{
|
||||
g_free (file);
|
||||
|
|
|
@ -1302,6 +1302,57 @@ midori_app_send_notification (MidoriApp* app,
|
|||
#endif
|
||||
}
|
||||
|
||||
static gchar** command_line = NULL;
|
||||
static gchar* exec_path = NULL;
|
||||
|
||||
/**
|
||||
* midori_app_get_command_line:
|
||||
*
|
||||
* Retrieves the argument vector passed at program startup.
|
||||
*
|
||||
* Return value: the argument vector
|
||||
*
|
||||
* Since: 0.4.7
|
||||
**/
|
||||
gchar**
|
||||
midori_app_get_command_line (void)
|
||||
{
|
||||
return command_line;
|
||||
}
|
||||
|
||||
/**
|
||||
* midori_app_find_res_filename:
|
||||
* @filename: a filename or relative path
|
||||
*
|
||||
* Looks for the specified filename in Midori's resources.
|
||||
*
|
||||
* Return value: a newly allocated full path
|
||||
*
|
||||
* Since: 0.4.7
|
||||
**/
|
||||
gchar*
|
||||
midori_app_find_res_filename (const gchar* filename)
|
||||
{
|
||||
gchar* path;
|
||||
|
||||
path = g_build_filename (exec_path, "share", PACKAGE_NAME, "res", filename, NULL);
|
||||
if (g_access (path, F_OK) == 0)
|
||||
return path;
|
||||
|
||||
g_free (path);
|
||||
|
||||
/* Fallback to build folder */
|
||||
path = g_build_filename (g_file_get_path (g_file_get_parent (
|
||||
g_file_get_parent (g_file_get_parent (g_file_new_for_path (exec_path))))),
|
||||
"data", filename, NULL);
|
||||
if (g_access (path, F_OK) == 0)
|
||||
return path;
|
||||
g_free (path);
|
||||
|
||||
return g_build_filename (MDATADIR, PACKAGE_NAME, "res", filename, NULL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* midori_app_setup:
|
||||
*
|
||||
|
@ -1352,9 +1403,6 @@ midori_app_setup (gchar** argument_vector)
|
|||
{ GTK_STOCK_DIRECTORY, N_("New _Folder"), 0, 0, NULL },
|
||||
};
|
||||
|
||||
/* Preserve argument vector */
|
||||
sokoke_get_argv (argument_vector);
|
||||
|
||||
/* libSoup uses threads, therefore if WebKit is built with libSoup
|
||||
* or Midori is using it, we need to initialize threads. */
|
||||
#if !GLIB_CHECK_VERSION (2, 32, 0)
|
||||
|
@ -1450,6 +1498,15 @@ midori_app_setup (gchar** argument_vector)
|
|||
g_object_unref (factory);
|
||||
#endif
|
||||
|
||||
/* Preserve argument vector */
|
||||
command_line = g_strdupv (argument_vector);
|
||||
#ifdef G_OS_WIN32
|
||||
exec_path = g_win32_get_package_installation_directory_of_module (NULL);
|
||||
#else
|
||||
exec_path = g_file_get_path (g_file_get_parent (g_file_get_parent (g_file_new_for_path (
|
||||
g_find_program_in_path (command_line[0])))));
|
||||
#endif
|
||||
|
||||
/* Print messages to stdout on Win32 console, cf. AbiWord
|
||||
* http://svn.abisource.com/abiword/trunk/src/wp/main/win/Win32Main.cpp */
|
||||
#ifdef _WIN32
|
||||
|
|
|
@ -85,6 +85,12 @@ midori_app_send_notification (MidoriApp* app,
|
|||
void
|
||||
midori_app_setup (gchar** argument_vector);
|
||||
|
||||
gchar**
|
||||
midori_app_get_command_line (void);
|
||||
|
||||
gchar*
|
||||
midori_app_find_res_filename (const gchar* filename);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __MIDORI_APP_H__ */
|
||||
|
|
|
@ -1128,7 +1128,7 @@ midori_view_web_view_resource_request_cb (WebKitWebView* web_view,
|
|||
|
||||
if (g_str_has_prefix (uri, "res://"))
|
||||
{
|
||||
gchar* filepath = sokoke_find_data_filename (&uri[6], TRUE);
|
||||
gchar* filepath = midori_app_find_res_filename (&uri[6]);
|
||||
gchar* file_uri = g_filename_to_uri (filepath, NULL, NULL);
|
||||
g_free (filepath);
|
||||
webkit_network_request_set_uri (request, file_uri);
|
||||
|
@ -1441,7 +1441,7 @@ midori_view_display_error (MidoriView* view,
|
|||
const gchar* try_again,
|
||||
WebKitWebFrame* web_frame)
|
||||
{
|
||||
gchar* path = sokoke_find_data_filename ("error.html", TRUE);
|
||||
gchar* path = midori_app_find_res_filename ("error.html");
|
||||
gchar* template;
|
||||
|
||||
if (g_file_get_contents (path, &template, NULL, NULL))
|
||||
|
@ -3977,7 +3977,7 @@ prepare_speed_dial_html (MidoriView* view,
|
|||
gchar** groups;
|
||||
|
||||
g_object_get (browser, "speed-dial", &key_file, NULL);
|
||||
file_path = sokoke_find_data_filename ("speeddial-head-" MIDORI_VERSION ".html", TRUE);
|
||||
file_path = midori_app_find_res_filename ("speeddial-head.html");
|
||||
|
||||
if (key_file != NULL
|
||||
&& g_access (file_path, F_OK) == 0
|
||||
|
@ -4245,7 +4245,7 @@ midori_view_set_uri (MidoriView* view,
|
|||
}
|
||||
else if (!strcmp (uri, "about:") || !strcmp (uri, "about:version"))
|
||||
{
|
||||
gchar* arguments = g_strjoinv (" ", sokoke_get_argv (NULL));
|
||||
gchar* arguments = g_strjoinv (" ", midori_app_get_command_line ());
|
||||
gchar* command_line = sokoke_replace_variables (
|
||||
arguments, g_get_home_dir (), "~", NULL);
|
||||
gchar* architecture, *platform;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "midori-core.h"
|
||||
#include "midori-platform.h"
|
||||
#include "midori-app.h"
|
||||
|
||||
#include <config.h>
|
||||
#if HAVE_UNISTD_H
|
||||
|
@ -496,7 +497,7 @@ void
|
|||
sokoke_spawn_app (const gchar* uri,
|
||||
gboolean private)
|
||||
{
|
||||
const gchar* executable = sokoke_get_argv (NULL)[0];
|
||||
const gchar* executable = midori_app_get_command_line ()[0];
|
||||
/* "midori"
|
||||
"/usr/bin/midori"
|
||||
"c:/Program Files/Midori/bin/midori.exe" */
|
||||
|
@ -1178,25 +1179,6 @@ sokoke_find_data_filename (const gchar* filename,
|
|||
return g_build_filename (MDATADIR, res1, res2, filename, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* sokoke_get_argv:
|
||||
* @argument_vector: %NULL
|
||||
*
|
||||
* Retrieves the argument vector passed at program startup.
|
||||
*
|
||||
* Return value: the argument vector
|
||||
**/
|
||||
gchar**
|
||||
sokoke_get_argv (gchar** argument_vector)
|
||||
{
|
||||
static gchar** stored_argv = NULL;
|
||||
|
||||
if (!stored_argv)
|
||||
stored_argv = g_strdupv (argument_vector);
|
||||
|
||||
return stored_argv;
|
||||
}
|
||||
|
||||
gchar*
|
||||
sokoke_replace_variables (const gchar* template,
|
||||
const gchar* variable_first, ...)
|
||||
|
|
5
wscript
5
wscript
|
@ -518,11 +518,8 @@ def build (bld):
|
|||
else:
|
||||
Utils.pprint ('BLUE', "logo-shade could not be rasterized.")
|
||||
|
||||
for res_file in ['about.css', 'error.html', 'close.png']:
|
||||
for res_file in ['about.css', 'error.html', 'close.png', 'speeddial-head.html']:
|
||||
bld.install_files ('${MDATADIR}/' + APPNAME + '/res', 'data/' + res_file)
|
||||
bld.install_as ( \
|
||||
'${MDATADIR}/' + APPNAME + '/res/speeddial-head-%s.html' % VERSION, \
|
||||
'data/speeddial-head.html')
|
||||
|
||||
if bld.env['addons']:
|
||||
bld.install_files ('${MDATADIR}/' + APPNAME + '/res', 'data/autosuggestcontrol.js')
|
||||
|
|
Loading…
Reference in a new issue