GNOME Bugzilla – Bug 734175
Can't open a text file from Nautilus
Last modified: 2014-08-12 09:12:19 UTC
If I try to open a text file with gedit from nautilus (either by double click or rightclick->Open With gedit), the file is not opened. I get the spinner mouse cursor for few seconds, and then nothing. When I do this, the process "/usr/bin/gedit --gapplication-service" starts, but then disappears after few seconds.
I guess this is a fallout of moving to dbus service stuff. Could you check if reverting https://git.gnome.org/browse/gedit/commit/?id=0dd265a74d91d804b0a54fa9d30ad75922e79015 fixes the problem?
Changing DBusActivatable to false in the desktop file does fix the problem.
What is your system setup? Are you using jhbuild, for example?
Normal Fedora 21 install.
I am guessing that nautilus uses dbus activation and so it starts gedit with "--gapplication-service" which in turn ignores any other argument. I have no idea how to solve this :)
The relevant call is here (I think): https://git.gnome.org/browse/glib/tree/gio/gdesktopappinfo.c#n2802 This should normally work fine. As far as I understood, when services are launched with -gapplication-service, there is a timeout where the app waits for either Open or Activate to be received. If it doesn't receive it, the app is closed (which is the behavior seen here). Would be useful to check with dbus-monitor what happens.
But we do not do "Open" because we manually handle the command line (needed to manage things like reading from stdin, --wait, etc)
As far as I can see, there is no problem supporting both. We handle command line args ourselves, so the default app implementation will not try to run Open for us when launching from the commandline. It should only do so when called over dbus (https://developer.gnome.org/gio/stable/GApplication.html#G-APPLICATION-HANDLES-OPEN:CAPS).
I guess it is true that we can *also* handle open. Ryan: is this how things should work?
<pbor> desrt: hi, so discussing https://bugzilla.gnome.org/show_bug.cgi?id=734175 in #gedit and looking at the code we have the impression that we need to implement *both* handle_command_line and open <pbor> desrt: so that when launched from command line, the first method is used and open is not called <pbor> desrt: while nautilus etc will use open directly <pbor> is that correct? <desrt> yes <pbor> cool <pbor> thanks, so we'll implement open <desrt> but only because you have this weird +nnn syntax <pbor> yeah, and stdin <desrt> otherwise you could strip out only the commandline args in handle_command_line and leave the rest to open/activated via the automatic handling <desrt> right. So yes, we need to add open()
Created attachment 283131 [details] [review] patch
Created attachment 283135 [details] [review] patch actually I do not think we can rely on activate to follow open, so instead lets' factor out a open_files helper and call it in both cases
Thanks, I can confirm this patch fixes the issue.
Review of attachment 283135 [details] [review]: I'd rather have this commit split into 2 patches. For one side the refactoring and from the other the handling of the open method ::: gedit/gedit-app.c @@ +87,1 @@ + /* command line parsing */ I guess this could go in a different commit first @@ +1004,3 @@ + GFile **files, + gint n_files, + const gchar *hint) wrong indentation?
amemnded as suggested and pushed