From: Christian Dywan Date: Thu, 31 May 2012 22:45:50 +0000 (+0200) Subject: Find extensions in runtime lib path X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=25d8b8ddfc8bbcb32ba60d33e3c240c50c5ca43c;p=midori Find extensions in runtime lib path Setting MIDORI_EXTENSION_PATH is no longer needed. --- diff --git a/INSTALL b/INSTALL index a81718ba..ad1dddbb 100644 --- a/INSTALL +++ b/INSTALL @@ -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 diff --git a/midori/main.c b/midori/main.c index f3c8bf25..d0f62df3 100644 --- a/midori/main.c +++ b/midori/main.c @@ -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) { diff --git a/midori/midori-app.c b/midori/midori-app.c index 8fdcac63..280ae1dc 100644 --- a/midori/midori-app.c +++ b/midori/midori-app.c @@ -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: diff --git a/midori/midori-app.h b/midori/midori-app.h index ffb03bc6..5a4b9b35 100644 --- a/midori/midori-app.h +++ b/midori/midori-app.h @@ -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__ */ diff --git a/midori/midori-preferences.c b/midori/midori-preferences.c index be60c466..4b5ff613 100644 --- a/midori/midori-preferences.c +++ b/midori/midori-preferences.c @@ -11,6 +11,7 @@ #include "midori-preferences.h" +#include "midori-app.h" #include "midori-platform.h" #include @@ -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); diff --git a/midori/sokoke.c b/midori/sokoke.c index 1428924a..c87c3c82 100644 --- a/midori/sokoke.c +++ b/midori/sokoke.c @@ -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 diff --git a/midori/sokoke.h b/midori/sokoke.h index a714cd98..375d8157 100644 --- a/midori/sokoke.h +++ b/midori/sokoke.h @@ -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); diff --git a/wscript b/wscript index 43963e62..a3513f5c 100644 --- a/wscript +++ b/wscript @@ -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')