Closed Bug 397700 Opened 13 years ago Closed 5 years ago

Implement application selector (nsIMIMEInfo.possibleLocalHandlers) for Linux

Categories

(Core Graveyard :: File Handling, defect, P3)

x86
Linux
defect

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1129873

People

(Reporter: dmose, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [proto])

Attachments

(2 files)

This is the Linux equivalent of bug 348808.  Requesting [wanted-1.9].
Flags: blocking1.9?
Flags: blocking1.9? → blocking1.9-
Whiteboard: [wanted-1.9]
Blocks: 348808
Blocks: 404434
Re-requesting blocking-1.9+, as it turns out this blocks bug 404434, and that already has blocking-1.9+.

Does anyone with GNOME experience have a take on how hard this would be (assuming it's possible)?
Flags: blocking1.9- → blocking1.9?
Whiteboard: [wanted-1.9] → [wanted-1.9] [proto]
+'ing and marking as P3 which aligns with bug 404434.
Flags: blocking1.9? → blocking1.9+
Priority: -- → P3
IIRC, there is no direct gnome API to get such a list, though it is not very difficult to do so.
Anyways, I think first having bug 373397 landed would help making it more easily. I'll post an updated patch soon.
Flags: wanted1.9+
Whiteboard: [wanted-1.9] [proto] → [proto]
Flags: tracking1.9+ → wanted-next+
The Gnome API to get the list of all applications registered for a mimetype call gnome_vfs_mime_get_all_application(const char *mimetype);

The implementation could look like:

NS_IMETHODIMP
nsGnomeVFSService::GetAllAppsForMimeType(const nsACString &aMimeType,
                                      nsIGnomeVFSMimeApp** aApp)
{
   *aApps = nsnull;
   GList *apps =
    gnome_vfs_mime_get_all_application(PromiseFlatCString(aMimeType).get());
 
    while(apps) {
       GList *next = apps->next;
       nsGnomeVFSMimeApp *mozApp = new nsGnomeVFSMimeApp(apps->data);
       NS_ENSURE_TRUE(mozApp, NS_ERROR_OUT_OF_MEMORY);

       NS_ADDREF(apps->data = mozApp);
   }
   return NS_OK;
}
Blocks: 370380
Similar to https://bugzilla.mozilla.org/show_bug.cgi?id=370380

Please try to implement a cross-desktop (xdg-* tool based?) solution.
Duplicate of this bug: 370380
Repeating my comment from the other bug since it doesn't sound like this addresses it:

-- The list of content types can't be modified, even to add something
identified only by file extension.  I just ran into this when trying to get a
.ssa file.  Firefox tried to open it and couldn't (not surprising).  There's no
way to add "file with extension ssa" to the content type list, and I have no
idea whatsoever whether Firefox thinks it has a mime type or is just treating
it as unknown.
-- On that subject, there's no entry for "unknown content type" (at least on my
machine).  Want to tell Firefox to save all files with an unknown content type?
 Forget it.
-- There's no way to tell Firefox whether to determine content type by
extension first or by Mime type sent by the server first.  I recently tried to
open a PDF file whose content type Firefox seemed to think was BIN.  There was
no way to tell Firefox that the .PDF in the filename takes precedence over the
bogus Mime type sent by the server.
-- There's usually no option "open in browser".  I want to tell Firefox to open
text files in Firefox.  Can't do that.
Hi,

  I've made a small patch in order to progress on this issue. It removes Firefox file system associations and forces use of xdg-open. I do not think this patch is complete since it's not cross-platform, but I really think it's a good step in order to solve this problem.
  There's already a file association mechanism on a Linux Desktop environments (Gnome, Kde, Xfce, Lxde, etc, etc). xdg-open is a simple way to use it. It simplifies lifes of users, which do not have to choose their preferred software twice, it simplifies lifes of integrators, which do not have to choose the default for their distributions twice and it simplifies source code of Firefox : there's no more need to get a file association mechanism compatible with all Linux Desktop environment.

  I don't know who will be a good "requestee" to ask for a review of this patch, so I've left the field empty.

Regards,
Attachment #373282 - Flags: review?
You will have to request a review requestee for this patch to be looked at formally (and I'm not one of them).

This seems to be unreliable; the system default program name is displayed in the application pref pane but this may not be the same as what xdg-open uses. And like you said, this isn't cross platform.
Michael Ventnor : You are on the root of this problem : 
* Does Firefox really needs to have its own application pref ? Is this not the job of a desktop environment ?

  With this patch, one can also unifiy the open with/save dialog box. Instead of having "open with" vs "save file", one can make "open file/save file" which seems more consistent and unified with other "file openers" like konqueror, dolphin, nautilus, internet explorer, etc. 
  Why Firefox should ask its user which software to use ? This is confusing and complicates lifes of both users, developers and packagers.

  I can make this patch cross-platform, with some #ifndef WIN32 or something similar. But is there a Firefox developer ready to apply this kind of patch ?
Duplicate of this bug: 490124
It should be noted that in KDE 4 the Open With dialoge can be accessed via the KOpenWithDialog class. This does require linking against kdebase, though. I do not know of a universal KDE / Gnome / *box solution, but please do not make this a Gnome-only solution. Should I ask on kde-devel or other lists how to access the Open With dialogue of the active desktop?

Thanks.
Duplicate of this bug: 492104
When you click on "open with" firefox should list available applications using
freedesktop specification instead of letting the (newbie or power)user looking
for the right folder containing the binary. Under any windows environment when
you click on a file that the environment does not know which application it
need to be launched with, it shows the user a list of all the different
application installed on the computer. WHy does firefow under linux does not
provide this kind of thing? Plus it is trivial to list all available
application by using freedesktop specification.
Personally it is a pan in the ass but as I deal quit well with my linux system
it is ok. But for newbies coming to the opensource/linux world, it is
completely destabilizing.
Thanks

Or yeah use xdg-open!!!
http://portland.freedesktop.org/xdg-utils-1.0/xdg-open.html
the use-case of opening a file could be:
(default -but rules could be specified by user to overpass the default association)
automatically use the preferred user's application using xdg-open.
IF NO preferred association found
THEN popup dialog to the user like this http://www.amsn-project.net/w/upload/a/ab/Screenshot-4-5.jpg
giving him the choice between manual path or a list of available application (using freedesktop standard specification)
..my two cents..
(In reply to comment #15)
> the use-case of opening a file could be:
> (default -but rules could be specified by user to overpass the default
> association)
> automatically use the preferred user's application using xdg-open.
> IF NO preferred association found
> THEN popup dialog to the user like this
> http://www.amsn-project.net/w/upload/a/ab/Screenshot-4-5.jpg
> giving him the choice between manual path or a list of available application
> (using freedesktop standard specification)
> ..my two cents..

Fx already supports this and an app picker dialog, we just need to figure out how to populate it by implementing possibleLocalHandlers. (See bug 348808)
(In reply to comment #16)
> (In reply to comment #15)
> > the use-case of opening a file could be:
> > (default -but rules could be specified by user to overpass the default
> > association)
> > automatically use the preferred user's application using xdg-open.
> > IF NO preferred association found
> > THEN popup dialog to the user like this
> > http://www.amsn-project.net/w/upload/a/ab/Screenshot-4-5.jpg
> > giving him the choice between manual path or a list of available application
> > (using freedesktop standard specification)
> > ..my two cents..
> 
> Fx already supports this and an app picker dialog, we just need to figure out
> how to populate it by implementing possibleLocalHandlers. (See bug 348808)

Moving to GVFS and GIO will make this easy. I'm hoping to do that (plus a bump to GTK 2.14) in the Firefox 3.next timeframe.
(In reply to comment #16)
> (In reply to comment #15)
> > the use-case of opening a file could be:
> > (default -but rules could be specified by user to overpass the default
> > association)
> > automatically use the preferred user's application using xdg-open.
> > IF NO preferred association found
> > THEN popup dialog to the user like this
> > http://www.amsn-project.net/w/upload/a/ab/Screenshot-4-5.jpg
> > giving him the choice between manual path or a list of available application
> > (using freedesktop standard specification)
> > ..my two cents..
> 
> Fx already supports this and an app picker dialog, we just need to figure out
> how to populate it by implementing possibleLocalHandlers. (See bug 348808)

You means in the dev branch, it is not released yet.right?


And to Micheal,  what is "Firefox 3.next timeframe."?  3.5 ?

thx
Duplicate of this bug: 428382
The app picker has been in since 3.0. We have two open bugs related to implementing the functionality on OSX and Linux, this bug and bug 397699. Once we have possibleLocalHandlers implemented, the app picker should "just work".
And does Fx will use by default the default application setting up in the desktop user like with xdg-open?
(In reply to comment #21)
> And does Fx will use by default the default application setting up in the
> desktop user like with xdg-open?

That may be a different bug. This bug is related to ease of use in choosing an alternative, non-default application. (In that we offer an alternative to the file picker dialog.) If there's a problem on Linux with Fx sending downloaded content to default handlers or if that functionality can be improved, we should spin off a different bug or (if applicable) re-open one of the dupes.
(In reply to comment #22)
> (In reply to comment #21)
> > And does Fx will use by default the default application setting up in the
> > desktop user like with xdg-open?
> 
> That may be a different bug. This bug is related to ease of use in choosing an
> alternative, non-default application. (In that we offer an alternative to the
> file picker dialog.) If there's a problem on Linux with Fx sending downloaded
> content to default handlers or if that functionality can be improved, we should
> spin off a different bug or (if applicable) re-open one of the dupes.

(Also - this bug relates to choosing the default handler in prefs, as it's called up there too.)
(The advantage of the implementation in my link is that it let the power-user to choose his local executable with an url.)

Ok I searched and did not find. So here is a new entry for the second part of my request an automaticaly call to default preferred user application [url=https://bugzilla.mozilla.org/show_bug.cgi?id=492276] bug 492276[/url]
(the first one was: choose file => choose application)
Duplicate of this bug: 464062
(In reply to comment #14)
> Plus it is trivial to list all available application by using freedesktop specification.
> [...]
> Or yeah use xdg-open!!!
> http://portland.freedesktop.org/xdg-utils-1.0/xdg-open.html

Whereas there is a FreeDesktop specification to retrieve the default application for a MIME type (xdg-open is one of the result), there is no FreeDesktop specification to retrieve the list of all registered applications for a MIME type (xdg-mime doesn't do that if you look at the man).

Considering the archives on xdg@lists.freedesktop.org, you'll see that there is no consensus on this, particularly on the way to deal with priorities of one application above the others (the preferred order of applications to handle a MIME type if you prefer).

I send you to http://lists.freedesktop.org/archives/xdg/2008-January/thread.html and the thread titled 'Default Program | File Association' to see what I mean (followed in February). I also send you to the FreeDesktop specifications page to see that there is nothing on this in current drafts: http://www.freedesktop.org/wiki/Specifications/. Don't hesitate to correct me if I'm wrong.

To be clear, I'm not saying this bug could not be solved, I'm saying it could not easily be done in a cross desktop way until there is no FreeDesktop consensus on this point.
If there is no freedesktop.org spec for calling the Open With... dialogue, then call the Gnome dialogue as default with an about:config option to use the KDE or other dialogue instead.
(In reply to comment #27)
> If there is no freedesktop.org spec for calling the Open With... dialogue, then
> call the Gnome dialogue as default with an about:config option to use the KDE
> or other dialogue instead.

Whereas there is such a dialog in KDE (KOpenWithDialog), there is no such thing yet in Gnome. The 'Open with…' dialog is hardwired in Nautilus (libnautilus). It's why it's not so simple.

The other problem is that you cannot wish that Firefox has a different behavior in Gnome and in KDE. There is a Linux packaging, not a Desktop packaging.

A possible way would be to put in firefox-gnome-support, and the equivalent for KDE, until there is a FreeDesktop spec, but it's no more upstream in this case.
I do not get at all what the discussion is about. We have support for finding the handler for an app at the moment using the gvfs interface. Just extend that interface to work with multiple applications and pipe the result into the app chooser. I posted how we could do that. There might be no standard, but why care? If there will be a standard it is most likley that it will go into the gvfs interface, so we do not even have to update the code after a proper standard has been established.
(In reply to comment #29)
> I do not get at all what the discussion is about. We have support for finding
> the handler for an app at the moment using the gvfs interface. Just extend that
> interface to work with multiple applications and pipe the result into the app
> chooser. I posted how we could do that. There might be no standard, but why
> care? If there will be a standard it is most likley that it will go into the
> gvfs interface, so we do not even have to update the code after a proper
> standard has been established.

You're right. We need a solution and cannot wait for standardization. But, this does not prevent us to plan for what must be realized on this subject from a short to longer term.

A quick solution:
-----------------
Develop specific and separate 'Open with…' implementation for Firefox for GTK desktops (Gnome & XFCE) and Qt ones (KDE).

The way to do this, for GTK, is as you said Clemens to use the Gnome library. GnomeVFS is now deprecated and GIO must be preferred. But we find the same methods (http://library.gnome.org/devel/gio/stable/GAppInfo.html#g-app-info-get-all) and your code could easily adapted.

The cons is that we have different implementations for Gnome/XFCE and KDE. Does Firefox can handle that, technically and formally? If not, those dev cannot be done upstream and must be made on firefox-gnome-support for instance.

The other con is that it will duplicate the code to produce an 'Open with…' dialog. Indeed, this code is already present in Nautilus. But this duplication is already done in existing Gnome apps.

The medium term plan:
------------------------

It would be great if Gnome dev, and specifically Nautilus ones, could extract the 'Open with…' code from Nautilus to be used externally. Good for Firefox and for all other application that need this code. Some talks about this here:http://markmail.org/message/mcarb3i4gg5hcvm3#query:+page:1+mid:qxaeqv22o3pkzgvx+state:results.

The long term plan:
-------------------

A FreeDesktop specification, standardizing the way to get the list of all applications registered for a mime-type and to open an 'Open with…' dialog would greatly simplify the work. An evolution of xdg-mime to get that list and not only the default application like now could be a way.

What do you think about this?
I do not understand why people are bringing up GNOME vs. KDE again and again here. We do support only GNOME at this time, and we're trying to use freedesktop where possible. There is no KDE support yet in Mozilla apps, and as much as I'd like to have it, we should not concern us with supporting something when the base for it isn't supported.
If it's easily enough possible, let's support the GNOME way now, and let's care about freedesktop when it has something for it, and about KDE integration once we have any base work for it in Mozilla code (this is not the bug for doing that base work).
I agree that we have first to correct the bug for Gnome. But this is not simply supporting or not KDE. I explain myself.

First point, the bug report is about Linux in general. Final users don't care if Firefox has only Gnome support, they want something that works under Linux cause there is a Linux build. It brings me to my second point.

We need to know if it's technically possible to distinguish the desktop the user is using. If something for Gnome is made, it could simply break this dialog under KDE if we can't detect the desktop environment. Indeed, if we call the Gnome API (GIO) in this case, it is not intended to be embedded in KDE, and this call will simply fail and break the dialog. It's not acceptable.

So can we detect easily in Firefox the desktop environment of the user to set a correction for Gnome in a first time that doesn't break KDE?
(In reply to comment #32)
> So can we detect easily in Firefox the desktop environment of the user to set a
> correction for Gnome in a first time that doesn't break KDE?

No, and we don't want to and don't need to. We call the GTK file and print dialogs, we're using GNOME stuff in multiple places, we are using theming from GTK, we don't do anything to even care if KDE is there or not, and the solution for this bug should also just ignore the fact. We don't run without GNOME libraries in any case, and there are no immediate plans to change that.
Ok. Thanks for this clarification.
Note : The bug Robert Kaiser is speaking of seems to be bug 140751
Robert Kaiser (In reply to comment #35)
> Note : The bug Robert Kaiser is speaking of seems to be bug 140751

Yes, already seen that and also this thread on Launchpad : https://bugs.launchpad.net/ubuntu/+source/firefox-3.0/+bug/220798 speaking of a malfunction of the applications preference tabs under KDE without the firefox-gnome-support package installed. It is why I care about that sort of thing. But, Robert Kaiser pointed that it is not the priority, so it's ok. One thing at a time.
Note that I'm a big KDE fan and user myself, but we need to stick with the way of things we have at Mozilla right now, and it's better to get one solution right (in Mozilla terms this needs to be the GNOME/GTK one) and only then work on improving it for others (like KDE) as well, in a new bug, and that might need some more general support code on a higher level than download file handling as well - but that's something to look at in a followup bug.

Let's first work constructively to come up with a solution on the GNOME/GTK terms Mozilla is already bound to (esp. as we already know that a really generic solution isn't possible at this moment, this is the next best thing for now).
Even as a KDE user, I agree that Firefox should code the support for Gnome. Firefox ignores everything KDE at the moment (such as File Chooser dialogues) and this is expected. Yes, it is annoying, but it is expected.
I'm also convince of this. I'm perfectly agree with you. I'm just quite new on this and I'm asking to get a clear view of the impacts of such a dev. It's know clear for me that we deal before with Gnome, will see in the future for KDE. A unified FreedDesktop spec would be a good way to alleviate the port of code from one to the other, but it's another debate.

New question now. About look-and-feel of this application selector dialog. Does it must stick with the native Gnome (or Nautilus in this case (attachment hereunder)) look-and-feel or does it must follow the Mozilla guidelines (https://wiki.mozilla.org/ContentHandling:User_Interface/Proposed_UI2) and what has made Jim Mathies on the subject for Windows (https://bug348808.bugzilla.mozilla.org/attachment.cgi?id=271748)?
(In reply to comment #40)
> Created an attachment (id=394231) [details]
> Nautilus 'open with…' dialog screenshot (french UI)


Which is what the patch in attachment 314945 [details] [diff] [review] from bug 428382 (dupe of this one now) was implementing.
(In reply to comment #39)
> New question now. About look-and-feel of this application selector dialog.

I think we'd need the input of the Mozilla UI team for a firm decision on that (though I expect them to prefer not creating a Linux-specific dialog).
What we can do without them is getting the backend right to get the information we want from GNOME and feed it to the interfaces that are already there from all I know.
And I think that's what we should stick to in this bug, any UI change following this or extending functionality e.g. to get info from elsewhere should be in followup bugs.
You have a patch on this bug that is flagged for 'review?' and not assigned to any reviewer. If you want the patch to be reviewed please assign a reviewer. Thanks
Attachment #373282 - Flags: review? → review?(ehsan.akhgari)
Attachment #373282 - Flags: review?(ehsan.akhgari) → review?(sdwilsh)
Comment on attachment 373282 [details] [diff] [review]
Removes file association mechanism of firefox and use xdg-open instead

I think Shawn is a better reviewer for this patch.
Comment on attachment 373282 [details] [diff] [review]
Removes file association mechanism of firefox and use xdg-open instead

This wouldn't work on anything but linux but it's a cross platform file
Attachment #373282 - Flags: review?(sdwilsh) → review-
Shawn : making it cross platform is not really difficult, since it's a tiny patch. What do you think of this approach ? If I make this patch cross-platform, would you integrate it ?
It seems this issue can be resolved using new features introduced in GTK 3.0

See: http://developer.gnome.org/gtk3/3.0/GtkAppChooser.html

and

http://developer.gnome.org/gtk3/3.0/GtkAppChooserDialog.html

The obvious first step that needs to be taken in the migration to GTK 3.0
Depends on: gtk3
This doesn't depend on GTK 3.0. The API's to get this information from the platform have existed already for a long time.

Is anyone interested in taking this? I'd like to get it fixed, so will take it if nobody steps up
No longer depends on: gtk3
There are bugs relating to this that dating back to 2004 I don’t think you will be treading on any toes by taking it up. 

As you can see by the previous posts the issue here has been finding a way to implement this so that it can be cross platform. What are the API's you are purposing to use to implement a solution?
(In reply to comment #48)
> This doesn't depend on GTK 3.0. The API's to get this information from the
> platform have existed already for a long time.

There are API's to get this information, yes, but GTK3 comes with an application selector dialog which would make fixing this bug much easier.
I would have to agree with Michael, using the supplied GTK3 dialog is a good long term fix, it will require little maintenance once implemented, and will present the user with a consistent dialog across the desktop once other applications start to implement this generic application selector.
Duplicate of this bug: 56662
Note that one of the dupes, (bug #56662) was filed in October 2000, and has had an unreviewed patch since August 2009. See patch details here:
https://bugs.launchpad.net/firefox/+bug/18995
Duplicate of this bug: 693318
Duplicate of this bug: 535634
This is my view of the perfect "Open with/Save" dialog:

"File: <name of the file> (type, size)"
Two tabs:  "Save as..." and "Open with..."
Under "Save as...", the typical "Save as" dialog.  By default, displaying the last directory selected, or the default one (usually "Downloads").
Under "Open with...", a list of installed applications.  The list will be headed by the 3 most used applications for that type.  If possible, it would be nice that the rest of applications were grouped by categories (Linux) or mimic the Start menu (Windows); this is how PCManFM looks and it's quite handy.  Under it, a "Custom command" box (which would allow to enter commands with arguments or paths to executables), optionally with a "Browse..." button.
At the bottom, the buttons "Ok" and "Cancel", and a "Do this automatically for this type" checkbox.

What do you think?
The missing application selector is also an issue when clicking a link with a HTML5 custom protocol and content handler. This (html5) becomes quite common now and it is almost an impertinence to force users to dig through the whole file system (as a work-around one could at least set the dialog to start at /usr/bin ). This needs a fix soon, if not in this decade then at least a usable work-around.
Willing to pay $150 to whoever fixes this issue. (or give it to the Mozilla foundation, whatever you prefer).
(In reply to Mathieu Comandon from comment #59)
> Willing to pay $150 to whoever fixes this issue. (or give it to the Mozilla
> foundation, whatever you prefer).
Within which timeframe? ;-)
(In reply to David Bruant from comment #60)
> (In reply to Mathieu Comandon from comment #59)
> > Willing to pay $150 to whoever fixes this issue. (or give it to the Mozilla
> > foundation, whatever you prefer).
> Within which timeframe? ;-)

Before end of April 2014. I'll give $200 if the bug is released with the firefox version shipped with Ubuntu 14.04 and $150 if the bugfix is still in Nightly by then.
(In reply to Mathieu Comandon from comment #62)
> (In reply to David Bruant from comment #60)
> > (In reply to Mathieu Comandon from comment #59)
> > > Willing to pay $150 to whoever fixes this issue. (or give it to the Mozilla
> > > foundation, whatever you prefer).
> > Within which timeframe? ;-)
> 
> Before end of April 2014. I'll give $200 if the bug is released with the
> firefox version shipped with Ubuntu 14.04 and $150 if the bugfix is still in
> Nightly by then.

Already July 2014. Bug still in Firefox.
(In reply to Michel Loiseleur from comment #8)
> Created attachment 373282 [details] [diff] [review]
> Removes file association mechanism of firefox and use xdg-open instead
> 
> Hi,
> 
>   I've made a small patch in order to progress on this issue. It removes
> Firefox file system associations and forces use of xdg-open. I do not think
> this patch is complete since it's not cross-platform, but I really think
> it's a good step in order to solve this problem.
>   There's already a file association mechanism on a Linux Desktop
> environments (Gnome, Kde, Xfce, Lxde, etc, etc). xdg-open is a simple way to
> use it. It simplifies lifes of users, which do not have to choose their
> preferred software twice, it simplifies lifes of integrators, which do not
> have to choose the default for their distributions twice and it simplifies
> source code of Firefox : there's no more need to get a file association
> mechanism compatible with all Linux Desktop environment.
> 
>   I don't know who will be a good "requestee" to ask for a review of this
> patch, so I've left the field empty.
> 
> Regards,

Your patch only for nsHelperAppDlg.js. It's for dialog of opening file. But it does not remove Firefox file system associations. And it does not change it for xdg-open. I just patched nsHelperAppDlg.js in root omni.ja.
Duplicate of this bug: 1116679
See Also: → 1129873
This is now implemented in the GTK3 build, after all these years I think its safe to say this won't get fixed in GTK2 so marking as duplicate of the bug report with the GTK3 implementation.
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 1129873
I have downloaded the last 64b linux version of Firefox (38.0.5) and it doesn't have implemented this.
I use Ubuntu 14.04 64b. It has the GTK3 libraries installed and in use.
For those finding this bug: It will be in Firefox 41
(In reply to Jesper Hansen from comment #68)
> For those finding this bug: It will be in Firefox 41

It will be in GTK3 builds of Firefox 41, which Firefox 41 as Mozilla ships it won't be.

GTK3 builds can however be dogfed: http://glandium.org/blog/?p=3555
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.