]> spindle.queued.net Git - midori/commitdiff
Find extensions in runtime lib path
authorChristian Dywan <christian@twotoasts.de>
Thu, 31 May 2012 22:45:50 +0000 (00:45 +0200)
committerChristian Dywan <christian@twotoasts.de>
Thu, 31 May 2012 22:57:49 +0000 (00:57 +0200)
Setting MIDORI_EXTENSION_PATH is no longer needed.

INSTALL
midori/main.c
midori/midori-app.c
midori/midori-app.h
midori/midori-preferences.c
midori/sokoke.c
midori/sokoke.h
wscript

diff --git a/INSTALL b/INSTALL
index a81718ba011bb6d39b2de78ab158e77b26f5832c..ad1dddbb6b8a911e483b0524ae969d8085cf1b68 100644 (file)
--- 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
index f3c8bf25980cc439f73fc7b28d35a4c9e63212a7..d0f62df3ba1afba4ae180b3e6d87fa9cd6b6f977 100644 (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)
         {
index 8fdcac63ac74c7f8f35b01684d1d5da7bad4817f..280ae1dc0c50b2504574665f5cb8eab666d058ea 100644 (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:
index ffb03bc6841adb760fe30a92f6bed8a1efdb009d..5a4b9b35a671c277d331863b534b7f34aca18461 100644 (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__ */
index be60c466b6be8a3388ad17e3a200c60b79ea372e..4b5ff61359d1415d0b6e76db07cc44e8e13cba5a 100644 (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);
index 1428924ad26995a2a202333ae71c7a267e97b417..c87c3c825d1081893024ae299609a1bcaf67573f 100644 (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
index a714cd98ad06b109ed0de40c07d10344d6abc6c1..375d8157282dc359933cb104f30c60931ae6f6d2 100644 (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);
diff --git a/wscript b/wscript
index 43963e625f8b9fc15e930701b87e54991dec77ed..a3513f5c86c8392004d36b34354fdbeb512eedac 100644 (file)
--- 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')