Find extensions in runtime lib path

Setting MIDORI_EXTENSION_PATH is no longer needed.
This commit is contained in:
Christian Dywan 2012-06-01 00:45:50 +02:00
parent c6f81c62e0
commit 25d8b8ddfc
8 changed files with 43 additions and 51 deletions

View File

@ -73,9 +73,8 @@ If you want to test bookmarks, you can enable database tracing:
To disable Netscape plugins, use MOZ_PLUGIN_PATH=/.
To debug extensions you can specify the path:
'export MIDORI_EXTENSION_PATH=_build/default/extensions'
When running from the build folder, extensions will also be located
in the build folder (setting MIDORI_EXTENSION_PATH is no longer needed).
For further information a tutorial for gdb and
reading up on how you can install debugging

View File

@ -1225,9 +1225,7 @@ midori_load_extensions (gpointer data)
gchar* extension_path;
GDir* extension_dir = NULL;
if (!(extension_path = g_strdup (g_getenv ("MIDORI_EXTENSION_PATH"))))
extension_path = sokoke_find_lib_path (PACKAGE_NAME);
if (extension_path != NULL)
if ((extension_path = midori_app_get_lib_path (PACKAGE_NAME)))
extension_dir = g_dir_open (extension_path, 0, NULL);
if (extension_dir != NULL)
{

View File

@ -1352,6 +1352,40 @@ midori_app_find_res_filename (const gchar* filename)
return g_build_filename (MDATADIR, PACKAGE_NAME, "res", filename, NULL);
}
/**
* midori_app_get_lib_path:
* @package: a filename or relative path
*
* Looks for the specified filename in Midori's library path.
*
* Return value: a newly allocated full path
*
* Since: 0.4.7
**/
gchar*
midori_app_get_lib_path (const gchar* package)
{
gchar* path;
path = g_build_filename (exec_path, "lib", package, NULL);
if (g_access (path, F_OK) == 0)
return path;
g_free (path);
if (!strcmp (package, PACKAGE_NAME))
{
/* Fallback to build folder */
path = g_build_filename (g_file_get_path (
g_file_new_for_path (exec_path)),
"extensions", NULL);
if (g_access (path, F_OK) == 0)
return path;
g_free (path);
}
return g_build_filename (MDATADIR, package, "lib", NULL);
}
/**
* midori_app_setup:

View File

@ -91,6 +91,9 @@ midori_app_get_command_line (void);
gchar*
midori_app_find_res_filename (const gchar* filename);
gchar*
midori_app_get_lib_path (const gchar* package);
G_END_DECLS
#endif /* __MIDORI_APP_H__ */

View File

@ -11,6 +11,7 @@
#include "midori-preferences.h"
#include "midori-app.h"
#include "midori-platform.h"
#include <string.h>
@ -365,7 +366,7 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
SPANNED_ADD (button);
/* Disable spell check option if there are no enchant modules */
{
gchar* enchant_path = sokoke_find_lib_path ("enchant");
gchar* enchant_path = midori_app_get_lib_path ("enchant");
if (enchant_path == NULL)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), FALSE);

View File

@ -1095,45 +1095,6 @@ sokoke_find_config_filename (const gchar* folder,
return g_build_filename (SYSCONFDIR, "xdg", PACKAGE_NAME, folder, filename, NULL);
}
/**
* sokoke_find_lib_path:
* @folder: the lib subfolder
*
* Looks for the specified folder in the lib directories.
*
* Return value: a newly allocated full path, or %NULL
**/
gchar* sokoke_find_lib_path (const gchar* folder)
{
#ifdef G_OS_WIN32
gchar* path = g_win32_get_package_installation_directory_of_module (NULL);
gchar* lib_path = g_build_filename (path, "lib", folder ? folder : "", NULL);
g_free (path);
if (g_access (lib_path, F_OK) == 0)
return lib_path;
#else
const gchar* lib_dirs[] =
{
LIBDIR,
"/usr/local/lib",
"/usr/lib",
NULL
};
guint i;
for (i = 0; i < G_N_ELEMENTS (lib_dirs); i++)
{
gchar* lib_path = g_build_filename (lib_dirs[i], folder ? folder : "", NULL);
if (g_access (lib_path, F_OK) == 0)
return lib_path;
else
g_free (lib_path);
}
#endif
return NULL;
}
/**
* sokoke_find_data_filename:
* @filename: a filename or relative path

View File

@ -136,9 +136,6 @@ gchar*
sokoke_find_config_filename (const gchar* folder,
const gchar* filename);
gchar*
sokoke_find_lib_path (const gchar* folder);
gchar*
sokoke_find_data_filename (const gchar* filename,
gboolean res);

View File

@ -605,7 +605,6 @@ def shutdown ():
except:
pass
try:
ext = 'MIDORI_EXTENSION_PATH=' + relfolder + os.sep + 'extensions'
nls = 'MIDORI_NLSPATH=' + relfolder + os.sep + 'po'
lang = os.environ['LANG']
try:
@ -622,7 +621,7 @@ def shutdown ():
'LC_MESSAGES' + os.sep + APPNAME + '.mo')
except:
pass
command = ext + ' ' + nls + ' '
command = nls + ' '
if is_mingw (Build.bld.env):
# This works only if everything is installed to that prefix
os.chdir (Build.bld.env['PREFIX'] + os.sep + 'bin')