[gnome-weather] Shuffle package.js around once more



commit 7f6c115cb2beda172c7614445eb45ff05c8328fa
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Mon Feb 3 19:41:21 2014 +0100

    Shuffle package.js around once more
    
    What we want here is quite complex:
    - ./src/gnome-weather should launch the app, no dbus involved, no
      service stuff, with local files
    - ./src/org.gnome.Weather.Application should launch the app
      as a service, with local files
      this will be used for uninstalled testing (because the test
      environment expects a dbus based app)
    - gnome-weather should send a dbus message and die immediately
    - $(pkgdatadir)/org.gnome.Weather.Application should launch the
      app as a service, with installed files

 src/main.js    |    7 +++----
 src/package.js |   14 ++++++++------
 2 files changed, 11 insertions(+), 10 deletions(-)
---
diff --git a/src/main.js b/src/main.js
index 3e333fe..2e43307 100644
--- a/src/main.js
+++ b/src/main.js
@@ -53,8 +53,10 @@ const Application = new Lang.Class({
 
     _init: function() {
         this.parent({ application_id: pkg.name,
-                      flags: Gio.ApplicationFlags.IS_SERVICE,
+                      flags: pkg.appFlags,
                       inactivity_timeout: 60000 });
+        if (this.flags & Gio.ApplicationFlags.IS_SERVICE)
+            this.inactivity_timeout = 60000;
         GLib.set_application_name(_("Weather"));
 
         this._searchProvider = new SearchProvider.SearchProvider(this);
@@ -117,9 +119,6 @@ const Application = new Lang.Class({
 
         this.add_accelerator("Escape", "win.selection-mode(false)", null);
         this.add_accelerator("<Primary>a", "win.select-all", null);
-
-        if (!pkg.moduledir.startsWith('resource://')) // running from source
-            this.activate();
     },
 
     vfunc_activate: function() {
diff --git a/src/package.js b/src/package.js
index 8a79c87..3ff427a 100644
--- a/src/package.js
+++ b/src/package.js
@@ -100,7 +100,7 @@ function _makeNamePath(name) {
  *
  * As a side effect, init() calls GLib.set_prgname().
  */
-function init(params) {
+function init(params, fromLauncher) {
     window.pkg = imports.package;
     name = params.name;
     version = params.version;
@@ -116,6 +116,9 @@ function init(params) {
     datadir = GLib.build_filenamev([prefix, 'share']);
     let libpath, girpath;
 
+    if (!fromLauncher)
+       appFlags |= Gio.ApplicationFlags.IS_SERVICE;
+
     if (_runningFromSource()) {
         log('Running from source tree, using local files');
         // Running from source directory
@@ -127,8 +130,6 @@ function init(params) {
         localedir = GLib.build_filenamev([_base, 'po']);
         moduledir = GLib.build_filenamev([_base, 'src']);
     } else {
-       appFlags |= Gio.ApplicationFlags.IS_SERVICE;
-
         _base = prefix;
         pkglibdir = GLib.build_filenamev([libdir, name]);
         libpath = pkglibdir;
@@ -167,10 +168,11 @@ function init(params) {
  * You must define a main(ARGV) function inside a main.js
  * module in moduledir.
  */
-function start(params, args) {
+function start(params, args, fromLauncher) {
     params.flags = params.flags || 0;
     args = args || ARGV;
-    init(params);
+    fromLauncher = !!fromLauncher;
+    init(params, fromLauncher);
 
     return imports.main.main(args);
 }
@@ -310,7 +312,7 @@ function launch(params) {
     let args = _parseLaunchArgs(ARGV, params);
 
     if (_runningFromSource()) {
-       return start(params, args);
+       return start(params, args, true);
     } else {
        params.flags |= Gio.ApplicationFlags.IS_LAUNCHER;
 


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