[gnome-music] Update package.js



commit 0331687d16a41e3ce6fda44f53ec26efb01e4a34
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Tue May 7 23:37:21 2013 +0200

    Update package.js
    
    Taken from gnome-weather.
    The update includes better recognition of source trees, and
    actual support for running from them (after at least one installation).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=700032
    
    Signed-off-by: Seif Lotfy <seif lotfy com>

 src/package.js |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/src/package.js b/src/package.js
index 67d98d1..35f3319 100644
--- a/src/package.js
+++ b/src/package.js
@@ -25,6 +25,7 @@
 
 const GLib = imports.gi.GLib;
 const GIRepository = imports.gi.GIRepository;
+const Gio = imports.gi.Gio;
 const System = imports.system;
 
 const Gettext = imports.gettext;
@@ -44,6 +45,19 @@ var localedir;
 let _base;
 let _requires;
 
+function _runningFromSource(name) {
+    if (System.version >= 13600) {
+        let fileName = System.programInvocationName;
+
+        let binary = Gio.File.new_for_path(fileName);
+        let cwd = Gio.File.new_for_path('.');
+        return binary.has_prefix(cwd);
+    } else {
+        return GLib.file_test(name + '.doap',
+                              GLib.FileTest.EXISTS);
+    }
+}
+
 /**
  * init:
  * @params: package parameters
@@ -100,8 +114,7 @@ function init(params) {
     datadir = GLib.build_filenamev([prefix, 'share']);
     let libpath, girpath;
 
-    if (GLib.file_test('./src',
-                       GLib.FileTest.IS_DIR)) {
+    if (_runningFromSource(name)) {
         log('Running from source tree, using local files');
         // Running from source directory
         _base = GLib.get_current_dir();
@@ -121,7 +134,7 @@ function init(params) {
         moduledir = pkgdatadir;
     }
 
-    imports.searchPath.push(moduledir);
+    imports.searchPath.unshift(moduledir);
     GIRepository.Repository.prepend_search_path(girpath);
     GIRepository.Repository.prepend_library_path(libpath);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]