We can drop the versioned filename.
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);
}
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);
#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:
*
{ 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)
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
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__ */
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);
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))
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
}
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;
#include "midori-core.h"
#include "midori-platform.h"
+#include "midori-app.h"
#include <config.h>
#if HAVE_UNISTD_H
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" */
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, ...)
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')