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 548767 - Add AI files (Adobe Illustrator) to "All Documents"
Add AI files (Adobe Illustrator) to "All Documents"
Status: RESOLVED DUPLICATE of bug 311990
Product: evince
Classification: Core
Component: backends
2.22.x
Other Linux
: Normal enhancement
: ---
Assigned To: Evince Maintainers
Evince Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-08-20 23:23 UTC by Chris Mohler
Modified: 2017-09-28 04:01 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
Adds 'application/illustrator' to PDF mimetypes (567 bytes, patch)
2008-09-15 23:21 UTC, Chris Mohler
none Details | Review
Illustrator file - version CS3 (13) (897.77 KB, application/illustrator)
2011-06-20 17:38 UTC, Chris Mohler
  Details
Illustrator file - version 8 (342.38 KB, application/illustrator)
2011-06-20 17:38 UTC, Chris Mohler
  Details
Adds application/illustrator to "All Documents" (1.19 KB, patch)
2013-06-18 02:28 UTC, Chris Mohler
rejected Details | Review

Description Chris Mohler 2008-08-20 23:23:06 UTC
Would be nice for .AI files to be included in the "All Documents" category of the open dialog.  Since Illustrator 9 (or earlier), AI files are just PDF and evince displays them just fine if you drag the selector to "All Files" or specify on the command line.
Comment 1 Chris Mohler 2008-09-15 23:21:54 UTC
Created attachment 118802 [details] [review]
Adds 'application/illustrator' to PDF mimetypes

Thought I'd take a shot at it.  This tiny patch (to SVN) seems to work, except for this: When opening a .AI file that is *not* PDF and will not load (Postscript error), a blank page is never rendered as it is in 2.22.2 - evince says "loading..." indefinitely.  Maybe I built the PS backend incorrectly?

I'm no C programmer - so feel free to chew me out if this the wrong way to go about it :)
Comment 2 Carlos Garcia Campos 2011-06-19 10:48:43 UTC
Do you have an AI file to test this? thanks.
Comment 3 Chris Mohler 2011-06-20 17:38:29 UTC
Created attachment 190296 [details]
Illustrator file - version CS3 (13)
Comment 4 Chris Mohler 2011-06-20 17:38:50 UTC
Created attachment 190297 [details]
Illustrator file - version 8
Comment 5 José Aliste 2013-04-04 02:00:14 UTC
Review of attachment 118802 [details] [review]:

Revisiting old bugs. This patch is wrong since a .ai file can be either a ps or a pdf... But if I run file -i test.ai to both tests I get correct mimetypes (meaning, ps and pdf mimetypes)
Comment 6 Chris Mohler 2013-04-04 02:11:40 UTC
I can try again if you could point me in the right direction.  It will be the weekend before I can bring my build environment up-to-date.

I'm not sure where to look, since as you mention old .AI files can be Postscript while newer versions are simply PDF.
Comment 7 José Aliste 2013-04-04 02:24:18 UTC
I am not sure... Evince already opens both test files. The problem is that you won't get the AI Documents neither Nautilus will let you choose evince to open an AI file... so there are two different things... the file mime-type gets detected... 

Actually evince open the files since there are two ways of getting the mime-type.. A fast way, which usually just checks the extension, and a non-fast way, which usually scans the file. So the .ai files will get application/illustrator if we get the mime-type with the fast way, and application/pdf or application/ps if we get the mime-type with the non-fast way. The only way I can think of doing this is by adding a new Ilustrator backend that detects the good mime-type and handles the rendering to the correct backend (ps or pdf)... or if we ever get a pspdf backend, we could add ai support to it.
Comment 8 José Aliste 2013-04-04 02:26:49 UTC
ah, I forgot, the problem with nautilus is fixed by adding application/illustration to the .desktop file of evince I guess
Comment 9 Chris Mohler 2013-04-04 02:37:25 UTC
Yeah - I think I have another patch for that on another bug.  IIRC it needs work too.
Comment 10 Germán Poo-Caamaño 2013-04-04 05:05:58 UTC
(In reply to comment #7)
> [...]
> Actually evince open the files since there are two ways of getting the
> mime-type.. A fast way, which usually just checks the extension, and a non-fast
> way, which usually scans the file. So the .ai files will get
> application/illustrator if we get the mime-type with the fast way, and
> application/pdf or application/ps if we get the mime-type with the non-fast
> way. The only way I can think of doing this is by adding a new Ilustrator
> backend that detects the good mime-type and handles the rendering to the
> correct backend (ps or pdf)... or if we ever get a pspdf backend, we could add
> ai support to it.

The non-fast way is very fast.  It just look a few byes (magic number).

According to http://en.wikipedia.org/wiki/Magic_number_%28programming%29#Magic_numbers_in_files

* PostScript files and programs start with "%!" (25 21).
* PDF files start with "%PDF" (hex 25 50 44 46).
Comment 11 Germán Poo-Caamaño 2013-04-04 05:28:36 UTC
It turns out there is a library (libmagic) which is BSD.  I do not think it worth to add a dependency for just 2 files.  However, the it might worth to take a look at that code.

https://github.com/glensc/file
Comment 12 José Aliste 2013-04-04 12:12:38 UTC
germán, there is already support for that in glib ;) the method for getting the mimetype has a boolean fast argument.
Comment 13 Chris Mohler 2013-06-18 02:28:40 UTC
Created attachment 247083 [details] [review]
Adds application/illustrator to "All Documents"

This works (opens both test cases attached here), yet prints out some ugly warnings when opening a Postscript AI file.  Example output:

Syntax Warning: May not be a PDF file (continuing anyway)
Syntax Error: Couldn't find trailer dictionary
Syntax Error: Couldn't read xref table

Somehow I think I'm doing this the wrong way.
Comment 14 Chris Mohler 2013-06-18 02:38:40 UTC
Actually that last patch is no good at all - sorry.  Correcting the ps backend to 'application/illustrator' (instead of "image/illustrator") just introduces segfaults.

So - it's safe to say I have no idea what I'm doing ;)
Comment 15 José Aliste 2014-09-10 15:01:05 UTC
Review of attachment 247083 [details] [review]:

This patch does not work. Unfortunately... mimetype based just on .ai extension is not usable since old .ai files are ps while newones are .pdf
Comment 16 Germán Poo-Caamaño 2017-09-28 04:01:52 UTC

*** This bug has been marked as a duplicate of bug 311990 ***