[Xfce4-commits] <midori:master> Find extensions in runtime lib path

Christian Dywan noreply at xfce.org
Fri Jun 1 00:58:04 CEST 2012


Updating branch refs/heads/master
         to 25d8b8ddfc8bbcb32ba60d33e3c240c50c5ca43c (commit)
       from c6f81c62e0a7e571e5fdac7944d9313bcbf2cded (commit)

commit 25d8b8ddfc8bbcb32ba60d33e3c240c50c5ca43c
Author: Christian Dywan <christian at twotoasts.de>
Date:   Fri Jun 1 00:45:50 2012 +0200

    Find extensions in runtime lib path
    
    Setting MIDORI_EXTENSION_PATH is no longer needed.

 INSTALL                     |    5 ++---
 midori/main.c               |    4 +---
 midori/midori-app.c         |   34 ++++++++++++++++++++++++++++++++++
 midori/midori-app.h         |    3 +++
 midori/midori-preferences.c |    3 ++-
 midori/sokoke.c             |   39 ---------------------------------------
 midori/sokoke.h             |    3 ---
 wscript                     |    3 +--
 8 files changed, 43 insertions(+), 51 deletions(-)

diff --git a/INSTALL b/INSTALL
index a81718b..ad1dddb 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 f3c8bf2..d0f62df 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 8fdcac6..280ae1d 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 ffb03bc..5a4b9b3 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 be60c46..4b5ff61 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 <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);
diff --git a/midori/sokoke.c b/midori/sokoke.c
index 1428924..c87c3c8 100644
--- a/midori/sokoke.c
+++ b/midori/sokoke.c
@@ -1096,45 +1096,6 @@ sokoke_find_config_filename (const gchar* folder,
 }
 
 /**
- * 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 a714cd9..375d815 100644
--- a/midori/sokoke.h
+++ b/midori/sokoke.h
@@ -137,9 +137,6 @@ 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 43963e6..a3513f5 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')


More information about the Xfce4-commits mailing list