Changeset 206:3cb84407dc3e
- Timestamp:
- 03/08/08 17:00:05
(6 months ago)
- Author:
- Frank Benoit <benoit@tionex.de>
- branch:
- default
- Message:
Temporary impl for Program.getExtensions on gnome 2.4
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r191 |
r206 |
|
| 29 | 29 | import tango.core.Array; |
|---|
| 30 | 30 | import tango.text.convert.Format; |
|---|
| | 31 | import tango.io.FileConduit; |
|---|
| | 32 | import tango.text.stream.LineIterator; |
|---|
| 31 | 33 | |
|---|
| 32 | 34 | version( build ){ |
|---|
| … | … | |
| 584 | 586 | } |
|---|
| 585 | 587 | |
|---|
| | 588 | /++ |
|---|
| | 589 | + DWT Extension |
|---|
| | 590 | + This is a temporary workaround until SWT will get the real implementation. |
|---|
| | 591 | +/ |
|---|
| | 592 | static char[][][ char[] ] gnome24_getMimeInfo() { |
|---|
| | 593 | scope file = new FileConduit ("/usr/share/mime/globs"); |
|---|
| | 594 | scope it = new LineIterator!(char)(file); |
|---|
| | 595 | // process file one line at a time |
|---|
| | 596 | char[][][ char[] ] mimeInfo; |
|---|
| | 597 | foreach (line; it ){ |
|---|
| | 598 | int colon = line.indexOf(':'); |
|---|
| | 599 | if( colon is line.length ){ |
|---|
| | 600 | continue; |
|---|
| | 601 | } |
|---|
| | 602 | if( line.length < colon+3 || line[colon+1 .. colon+3 ] != "*." ){ |
|---|
| | 603 | continue; |
|---|
| | 604 | } |
|---|
| | 605 | char[] mimeType = line[0..colon].dup; |
|---|
| | 606 | char[] ext = line[colon+3 .. $].dup; |
|---|
| | 607 | if( auto exts = mimeType in mimeInfo ){ |
|---|
| | 608 | mimeInfo[ mimeType ] = *exts ~ ext; |
|---|
| | 609 | } |
|---|
| | 610 | else{ |
|---|
| | 611 | mimeInfo[ mimeType ] = [ ext ]; |
|---|
| | 612 | } |
|---|
| | 613 | } |
|---|
| | 614 | return mimeInfo; |
|---|
| | 615 | } |
|---|
| 586 | 616 | /** |
|---|
| 587 | 617 | * GNOME - Get mime types |
|---|
| … | … | |
| 728 | 758 | char[][][ char[] ] mimeInfo = null; |
|---|
| 729 | 759 | switch (desktop) { |
|---|
| 730 | | case DESKTOP_GNOME_24: break; |
|---|
| | 760 | case DESKTOP_GNOME_24: mimeInfo = gnome24_getMimeInfo(); break; |
|---|
| 731 | 761 | case DESKTOP_GNOME: mimeInfo = gnome_getMimeInfo(); break; |
|---|
| 732 | 762 | //case DESKTOP_CDE: mimeInfo = cde_getDataTypeInfo(); break; |
|---|
| 733 | 763 | default: |
|---|
| 734 | 764 | } |
|---|
| 735 | | if (mimeInfo is null) return new char[][0]; |
|---|
| | 765 | if (mimeInfo is null) return null; |
|---|
| 736 | 766 | |
|---|
| 737 | 767 | /* Create a unique set of the file extensions. */ |
|---|