After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 710965 - GApplication: add --gapplication-service switch
GApplication: add --gapplication-service switch
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: gapplication
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2013-10-27 15:36 UTC by Allison Karlitskaya (desrt)
Modified: 2018-05-24 15:46 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GApplication: add --gapplication-service switch (2.01 KB, patch)
2013-10-27 15:36 UTC, Allison Karlitskaya (desrt)
reviewed Details | Review
GApplication: add --gapplication-service switch (3.44 KB, patch)
2014-01-09 21:16 UTC, Allison Karlitskaya (desrt)
committed Details | Review
gapplication: allow --service option (1.17 KB, patch)
2015-02-03 13:55 UTC, Lars Karlitski
none Details | Review

Description Allison Karlitskaya (desrt) 2013-10-27 15:36:34 UTC
This will allow apps to take advantage of the glory of DBusActivatable
without the pain.
Comment 1 Allison Karlitskaya (desrt) 2013-10-27 15:36:36 UTC
Created attachment 258223 [details] [review]
GApplication: add --gapplication-service switch

Add a --gapplication-service switch to the default implementation of
local_command_line.  This name is unlikely to clash with any option used
by an existing application.

When a normal application (neither service nor launcher) is launched with
exactly this one argument, G_APPLICATION_IS_SERVICE will be set.

The idea is that people will write their D-Bus service file with
--gapplication-service on the Exec line.  This provides a nice
compromise for people who want the benefits of DBusActivatable
applications but without losing the ability to easily run them directly
(under the debugger or inside jhbuild, etc.)
Comment 2 Matthias Clasen 2013-10-27 22:23:06 UTC
That seems a little hacky, not a fan. You shot down my patch to handle --version in this way.

I can see this leading to badly implemented services that open windows even when launched as a service.
Comment 3 Allison Karlitskaya (desrt) 2013-10-28 18:09:06 UTC
Can you elaborate?
Comment 4 Matthias Clasen 2013-11-01 10:05:01 UTC
After I turned gnome-software into a service, I had to do this:

https://git.gnome.org/browse/gnome-software/commit/?id=84666d65017367a2d935d65dc69ca4d16d523827
Comment 5 Matthias Clasen 2013-12-21 03:26:04 UTC
After writing some tests for gnome-software, I'm coming around to the idea that it is very nice to have a single binary for both purposes.
Comment 6 Matthias Clasen 2013-12-21 16:31:25 UTC
Review of attachment 258223 [details] [review]:

This needs documententation, probably in the same place where we discuss commandline handling and service-vs-launcher. Would also be great to have a testcase for this.

::: gio/gapplication.c
@@ +489,3 @@
+          return TRUE;
+        }
+    }

This means that 

fake-sunset --extra-glow --gapplication-service

will not work, and will likely make fake-sunset complain about an unknown option later. Is that intended ?

fake-sunset --gapplication-service --extra-glow

will start a sunset service, but is still likely to complain about an unknown option. Should you strip the processed option from the arguments ? Or is the idea that --gapplication-service can only be used as the sole option ? In that case, you should perhaps warn if there are other options, not silently ignore them ?
Comment 7 Allison Karlitskaya (desrt) 2014-01-09 21:06:42 UTC
(In reply to comment #6)
> Or is the
> idea that --gapplication-service can only be used as the sole option ? In that
> case, you should perhaps warn if there are other options, not silently ignore
> them ?

This is precisely the idea.  This should be used from only one place: the service file with exactly the one argument.  Adding a warning if other arguments are there might be a nice idea, indeed.
Comment 8 Allison Karlitskaya (desrt) 2014-01-09 21:16:06 UTC
Created attachment 265877 [details] [review]
GApplication: add --gapplication-service switch

Add a --gapplication-service switch to the default implementation of
local_command_line.  This name is unlikely to clash with any option used
by an existing application.

When a normal application (neither service nor launcher) is launched with
exactly this one argument, G_APPLICATION_IS_SERVICE will be set.

The idea is that people will write their D-Bus service file with
--gapplication-service on the Exec line.  This provides a nice
compromise for people who want the benefits of DBusActivatable
applications but without losing the ability to easily run them directly
(under the debugger or inside jhbuild, etc.)
Comment 9 Allison Karlitskaya (desrt) 2014-01-09 21:24:48 UTC
May also be interesting to have a proper 'hybrid' mode:

 - by default, the process is a launcher

 - if --gapplication-service is given, then it's a service

 - if --gapplication-local is given then it's neither

This means that normal invocations would active the service in the usual way but we could use --gapplication-local to short-circuit that for the case where we want to debug the app or have problems with D-Bus activation (like with jhbuild).

I think this is pretty heavy, though, and it would only be useful for processes that care about the life-cycle of processes launched from the commandline.  Those applications are in a fine position to add these features to their own local_command_line().

That said, this may be something we care about more going forward, if we start to consider the cgroup separation that we get from D-Bus activation to be important.
Comment 10 Matthias Clasen 2014-01-09 22:46:34 UTC
Review of attachment 265877 [details] [review]:

Ok. Would be good to have a test exercising this.
Comment 11 Allison Karlitskaya (desrt) 2014-01-10 14:30:03 UTC
Comment on attachment 265877 [details] [review]
GApplication: add --gapplication-service switch

Attachment 265877 [details] pushed as e8b7dd3 - GApplication: add --gapplication-service switch

Testing this is going to be pretty difficult...
Comment 12 Lars Karlitski 2015-02-03 13:55:55 UTC
Created attachment 296020 [details] [review]
gapplication: allow --service option

--service reads much nicer and I just did the same for --app-id.

--gapplication-service will continue to work.
Comment 13 GNOME Infrastructure Team 2018-05-24 15:46:50 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/770.